Leaflet - get latitude and longitude of a marker inside a pop-up

前端 未结 1 384
隐瞒了意图╮
隐瞒了意图╮ 2021-01-06 06:04

I use the Leaflet Draw plugin.
My goal is to create markers and show a pop up in which I can get latitude and longitude coordinates.
I manage to get these coordinate

相关标签:
1条回答
  • 2021-01-06 06:25
    map.on('draw:created', function (e) {
        var type = e.layerType,
            layer = e.layer;
    
        map.addLayer(layer);
    
        if (type === 'marker') {    
            layer.bindPopup('LatLng: ' + layer.getLatLng()).openPopup();
        }
    
    });
    
    0 讨论(0)
提交回复
热议问题