Marker in leaflet, click event

后端 未结 5 1298
北海茫月
北海茫月 2020-12-04 19:12
var map = L.map(\'map\');
var marker = L.marker([10.496093,-66.881935]).on(\'click\', onClick);
function onClick(e) {alert(e.latlng);}
marker.addTo(map)
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 19:38

    I found the solution:

    function onClick(e) {alert(this.getLatLng());}
    

    used the method getLatLng() of the marker

提交回复
热议问题