update marker location with leaflet API

后端 未结 2 555
说谎
说谎 2021-02-05 00:50

I want to build web app with the Leaflet API. First my user is geolocated with IP then if he accepts I try to update his position with HTML5 geolocation (accuracy is better).

2条回答
  •  青春惊慌失措
    2021-02-05 01:33

    Try update() of marker method it works for me

    var lat = (e.latlng.lat);
    var lng = (e.latlng.lng);
    marker.setLatLng([lat, lng]).update();  // Updates your defined marker position
    

提交回复
热议问题