Project

General

Profile

How to move a Marker that has been added to LeafletMap

Added by Clément LE BIHAN over 1 year ago

Hi,

I'm trying to show GPS coordinates of a connected sensor on a LeafletMap.

I didn't find any example on how to move marker that has been added to the map.

As soon as I add a marker to the map using cpp addMarker (std::unique_ptr< Marker > marker) I lose the ownership on my marker.
And I can't move it as I don't have the pointer anymore because I gave a unique_ptr ...

Any help ?

Best,
Clément


Replies (2)

RE: How to move a Marker that has been added to LeafletMap - Added by Roel Standaert over 1 year ago

I suppose it would be convenient if addMarker returned the marker you gave it.

For now, you can just use .get() on the unique_ptr before you add it to get a non-owning pointer, that you can then call move on.

RE: How to move a Marker that has been added to LeafletMap - Added by Clément LE BIHAN over 1 year ago

Hi @Roel Janssen,

I did it and it works :)
I didn't feel confortable to store the pointer of a unique ptr in an other pointer, but if it's the only solution I take it :D

I have an other question on LeafletMap. I can see I can add a polyline (to draw the trajectory of my GPS sensor). Is there a way to update this polyline ? Or is there a way to remove and add a new one ?

Best,
Clément

    (1-2/2)