Closed giswqs closed 5 months 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.
Make sense. The combination of m.add_source()
and m.set_data()
solves the issue.
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/