polygon_map 0.0.4 copy "polygon_map: ^0.0.4" to clipboard
polygon_map: ^0.0.4 copied to clipboard

A flexible Flutter map widget for creating, editing, and managing polygons with interactive controls.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:polygon_map/polygon_map.dart';
import 'package:latlong2/latlong.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final controller = PolygonMapController();

  @override
  void initState() {
    super.initState();

    controller.addListener(_onControllerChanged);

    controller.setPolygons([
      PolygonModel(
        borderColor: Colors.red,
        points: [
          LatLng(34.0925, -118.2750),
          LatLng(34.0925, -118.2050),
          LatLng(34.0225, -118.1950),
          LatLng(34.0125, -118.2050),
          LatLng(34.0125, -118.2750),
        ],
      ),
    ]);
  }

  void _onControllerChanged() {
    debugPrint("last polygon: ${controller.polygons.last.points}");
  }

  @override
  void dispose() {
    controller.removeListener(_onControllerChanged);
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: PolygonMap(
          controller: controller,
          mapType: MapTypeEnum.esriSatellite,
        ),
      ),
    );
  }
}
0
likes
0
points
186
downloads

Publisher

verified publisherrony.fun

Weekly Downloads

A flexible Flutter map widget for creating, editing, and managing polygons with interactive controls.

Repository (GitHub)
View/report issues

Topics

#polygon #geospatial #drawing #interactive #geolocation

License

unknown (license)

Dependencies

flutter, flutter_map, latlong2

More

Packages that depend on polygon_map