[Leaflet Mobile Plugin] How to change location of markers dynamically?

Forge Component
Published on 2019-10-12 by Vincent Koning
1 vote
Published on 2019-10-12 by Vincent Koning


Is it possible to change location of a marker dynamically (by an event)? I didn't find changeMarker of deleteMarkr functions in the plugin.

Do you mean by dragging the marker ?

You can delete the previously created marker, before creating a new  one by adding below code in AddMarker

If(DeleteOldMarker, (EncodeJavaScript(LeafletMapName) + ".removeLayer("+EncodeJavaScript(Marker.Name) +");"),"")

You can also use the Hide and Show actions


Stefano Valente wrote:

Do you mean by dragging the marker ?

I mean by changing lat, lon parameters of marker.

I found out in the documentation to the LeafletJS library that there is a method setLatLon of the object Marker. 

First careate js script text:

"var myLatLonObject = L.latLng(" + EncodeJavaScript(MyLocation.Latitude) +", " + EncodeJavaScript(MyLocation.Longitude) + "); " +
EncodeJavaScript(MyPositionMarkerName) + ".setLatLng(myLatLonObject);"

Second run this script by eval($parameters.Script);

Is works.


I'll try to free up some time this weekend and update the component to include this function :)