eodaGmbH / py-maplibregl

Python bindings for MapLibre GL JS
https://eodagmbh.github.io/py-maplibregl/
MIT License
27 stars 2 forks source link

Update Marker location #67

Closed giswqs closed 1 week ago

giswqs commented 1 week ago

MapLibre JS Marker has a setLngLat() method for updating marker location. Is it possible to support this as well?

Use case: https://maplibre.org/maplibre-gl-js/docs/examples/animate-marker/

crazycapivara commented 1 week ago

There is no out-of.the-box solution, because MapLibre's Map object does not store markers in the way it does for sources and layers, where you can get them by id in order to update them. But I could create on object, where markers are stored if we pass an ID, like Map.add_marker(..., id=None). Then a function Map.set_marker(id, lng_lat) could update the Marker. If you do not explicitly need a marker, you could update a data source instead as shown in this example.

giswqs commented 1 week ago

Make sense. The combination of m.add_source() and m.set_data() solves the issue.