How do I get the latlng after the dragend event in leaflet?

前端 未结 4 1033
陌清茗
陌清茗 2021-01-07 18:55

I\'m trying to update the lat/lng value of a marker after it is moved. The example provided uses a popup window to display the lat/lng.

I have a \"dragend\" event l

4条回答
  •  情深已故
    2021-01-07 19:27

    While using e.target._latlng works (as proposed by this other answer), it's better practice to use

    e.target.getLatLng();
    

    That way we're not exposing any private variables, as is recommended by Leaflet:

    Private properties and methods start with an underscore (_). This doesn’t make them private, just recommends developers not to use them directly.

提交回复
热议问题