ibrierley / flutter_map_dragmarker

A drag marker for flutter_map
BSD 3-Clause "New" or "Revised" License
54 stars 37 forks source link

flutter_map_dragmarker

A drag marker for flutter_map.

See the example/lib/main.dart for usage, but the included example below in this file should show pretty much everything.

ko-fi

Usage

  FlutterMap(
    options: MapOptions(center: LatLng(45.5231, -122.6765), zoom: 9),
    children: [
      TileLayer(
        urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
      ),
      DragMarkers(
        markers: [
          DragMarker(
            point: LatLng(45.535, -122.675),
            offset: const Offset(0.0, -8.0),
            builder: (ctx) => const Icon(Icons.location_on, size: 50),
            onDragUpdate: (details, latLng) => print(latLng),
          ),
        ],
      ),
    ],
  ),

Further notes

It may be interesting to move the map alternately to marker, too. So the marker stays in place, but then technically you aren't dragging anymore, so thoughts welcome.