Flutter_map: Draggable Markers

Created on 27 Mar 2018  路  8Comments  路  Source: fleaflet/flutter_map

Is there an easy way to make markers draggable around the map? I tried with a GestureDetector and using onPanDown, but the problem is once the marker is released you get screen coordinates and not GPS coordinates.

Most helpful comment

If the MapState is exposed you can then call its project and unproject methods to convert between screen points and map coordinates.

All 8 comments

not currently. This feature would involve other things too (like moving the map when the marker is at the edge)

We could expose gesture detection handlers through the public API to make this work once https://github.com/apptreesoftware/flutter_map/issues/10 is added

Sounds good!

In case anyone finds this issue in the future: one workaround is to allow some sort of edit mode triggered by longpressing on a marker, where you then grab wherever the user next taps on the map and move the marker to that spot.

If the MapState is exposed you can then call its project and unproject methods to convert between screen points and map coordinates.

This should be possible using the Plugin api, which exposes the full MapState object, and allows you write custom layers: https://github.com/apptreesoftware/flutter_map/blob/master/flutter_map_example/lib/pages/plugin_api.dart

@avioli Draggable widget only gives me offset. How to convert offset to Point object?

Is that feature (Draggable Marker) already implemented? If yes - any example hint how it might be used ?

Not that I'm aware of. If someone would like to contribute an example I can re-purpose this issue for that.

If anyone is still interested in this, I've started a draggable marker plugin over at https://github.com/ibrierley/flutter_map_dragmarker/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SamuelRioTz picture SamuelRioTz  路  4Comments

JonasVautherin picture JonasVautherin  路  4Comments

garrrettt picture garrrettt  路  3Comments

abhijithvijayan picture abhijithvijayan  路  4Comments

zozeei picture zozeei  路  4Comments