xy_maps

xy_maps is a Flutter package that allows placing rich-commented markers on custom image backgrounds (e.g. floor plans). Users can zoom, pan, switch between edit/view mode, and export/import marker data using a GeoJSON-like format.

✨ Features

  • πŸ—ΊοΈ Custom image as a map (e.g., floor plan, site layout)
  • πŸ” Pinch to zoom and pan support via InteractiveViewer
  • πŸ–±οΈ Tap to place markers in edit mode
  • πŸ“ Add rich text comments (bold, italics, bullets, links) with flutter_quill
  • 🧭 Edit/view mode toggle
  • πŸ”„ Move existing markers
  • πŸ—ƒοΈ GeoJSON-compatible import/export format
  • βš™οΈ State management with provider

πŸ“¦ Installation

Add the package in your pubspec.yaml:

dependencies:
  xy_maps: ^0.0.2

Then run:

flutter pub get

πŸš€ Getting Started

1. Wrap your widget tree in ChangeNotifierProvider

ChangeNotifierProvider(
  create: (_) => MarkerController(),
  child: MyApp(),
);

2. Add XyMapView to your widget tree

XyMapView(
  backgroundImage: AssetImage('assets/floorplan.png'),
  imageWidth: 1920,
  imageHeight: 1080,
  onMarkerAdded: (marker) {
    print('New marker: (${marker.x}, ${marker.y})');
  },
);

3. Switch between view and edit modes

final controller = context.read<MarkerController>();
controller.setMode(ViewMode.edit); // or ViewMode.view

πŸ“ Marker Format

Marker data is represented in a GeoJSON-like format:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [0.5, 0.3]
      },
      "properties": {
        "comment": { "ops": [{ "insert": "Hello marker!\n" }] }
      }
    }
  ]
}

Use GeoJsonMarker.toJson() and GeoJsonMarker.fromJson() for conversion.

πŸ§ͺ Example

To try it out quickly:

git clone https://github.com/ExploreAritra/xy_maps.git
cd xy_maps/example
flutter run

πŸ–ΌοΈ Screenshots

Drawing Usage

πŸ‘¨β€πŸ’» Contributing

Pull requests are welcome! Please open issues for feature requests or bugs.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Developed by @ExploreAritra

Libraries

xy_maps