admin管理员组文章数量:1389829
My goal is to get Latitude and Longitude coordinates as soon as I draw a marker.
I managed to do that with that snippet (see Leaflet - get latitude and longitude of a marker inside a pop-up) :
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();
}
});
But I'd like to get the first three decimals of latitude and longitude, like 35.567 and 105.891.
Is it possible to do that with Leaflet and how ?
Thanks !
My goal is to get Latitude and Longitude coordinates as soon as I draw a marker.
I managed to do that with that snippet (see Leaflet - get latitude and longitude of a marker inside a pop-up) :
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();
}
});
But I'd like to get the first three decimals of latitude and longitude, like 35.567 and 105.891.
Is it possible to do that with Leaflet and how ?
Thanks !
1 Answer
Reset to default 9layer.getLatLng().lat.toFixed(3)
See the JavaScript number object.
本文标签: javascriptLeafletget the first three decimals of Longitude and LatitudeStack Overflow
版权声明:本文标题:javascript - Leaflet - get the first three decimals of Longitude and Latitude - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744691829a2620042.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论