google_maps_drawing_tools 0.0.6
google_maps_drawing_tools: ^0.0.6 copied to clipboard
A Flutter plugin that adds drawing tools (polygons, circles, rectangles) on Google Maps, enabling users to interactively draw and edit shapes within a Flutter application.
πΊοΈ google_maps_drawing_tools #
A powerful Flutter package that brings advanced drawing tools to Google Maps.
With support for polygons, rectangles, and circles, it enables interactive drawing, editing, and customization directly on the map.
Ideal for applications involving geofencing, region selection, and spatial data visualization.
β¨ Features #
- Interactive Drawing: Draw polygons, rectangles, and circles directly on the map with intuitive gestures.
- Editing Capabilities: Modify shapes by dragging vertices or edges.
- Customizable Styles: Adjust stroke and fill colors and other styling options.
- Selection & Deletion: Tap to select shapes and remove them as needed.
- Import & Export: Import and export shapes in GeoJSON format.
- Event Callbacks: Hook into drawing and editing events for custom behaviors.
- Modular Architecture: Clean codebase designed for easy integration and extension.
π¦ Installation #
Add the package to your pubspec.yaml
:
dependencies:
google_maps_drawing_tools: ^0.0.6
Then, run:
flutter pub get
Setup Requirement #
Before using this package, make sure you have set up correctly by following its official instructions here
.
π οΈ Usage #
1. Initialize the Drawing Controller #
final drawingController = DrawingController();
2. Integrate with GoogleMap Widget #
DrawingMapWidget(
initialCameraPosition: CameraPosition(
target: LatLng(37.7749, -122.4194),
zoom: 14,
),
controller: drawingController,
webGestureHandling: WebGestureHandling.cooperative,
// ... other Google map properties
)
3. Start Drawing #
// To start drawing a polygon
drawingController.startDrawing(DrawMode.polygon);
// To start drawing a rectangle
drawingController.startDrawing(DrawMode.rectangle);
// To start drawing a circle
drawingController.startDrawing(DrawMode.circle);
4. Finish Drawing #
drawingController.finishDrawing();
5. Update Shape Color #
drawingController.updateColor(shapeId, newColor);
6. Delete a Shape #
drawingController.deleteShape(shapeId);
πΈ Screenshots #
π§ͺ Example #
An example application demonstrating the package's capabilities is available in the example/
directory.
To run it:
Add MAPS_API_KEY=Your_API_Key to local.properties inside the example/android directory.
cd example
flutter run
π License #
This project is licensed under the MIT License. See the LICENSE file for details.
π Contributions #
Contributions are welcome!
Feel free to submit issues or pull requests to enhance the package.
For more details and updates, visit the google_maps_drawing_tools GitHub repository.