2019-02-01 14:58:26 +03:00
|
|
|
'use strict';
|
2019-01-29 10:36:46 +03:00
|
|
|
|
2019-02-01 14:58:26 +03:00
|
|
|
// coord display
|
|
|
|
var CoordinatesDisplay = L.Control.extend({
|
|
|
|
onAdd: function(map) {
|
|
|
|
var div = L.DomUtil.create('div', 'leaflet-bar leaflet-custom-display');
|
2019-02-08 16:48:06 +03:00
|
|
|
|
|
|
|
var hoverCoord, clickCoord
|
|
|
|
|
|
|
|
function updateHover(ev){
|
|
|
|
hoverCoord = ev.latlng;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateClick(ev){
|
|
|
|
clickCoord = ev.latlng;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
function update(){
|
|
|
|
var html = "";
|
|
|
|
if (hoverCoord)
|
|
|
|
html += = "X=" + parseInt(hoverCoord.lng) + " Z=" + parseInt(hoverCoord.lat);
|
|
|
|
|
|
|
|
if (clickCoord)
|
|
|
|
html += = " (marked: X=" + parseInt(clickCoord.lng) + " Z=" + parseInt(clickCoord.lat) + ")";
|
|
|
|
|
|
|
|
div.innerHTML = html;
|
2019-02-01 14:58:26 +03:00
|
|
|
}
|
2019-01-29 10:36:46 +03:00
|
|
|
|
2019-02-08 16:48:06 +03:00
|
|
|
map.on('mousemove', updateHover);
|
|
|
|
map.on('click', updateClick);
|
|
|
|
map.on('touch', updateClick);
|
2019-01-29 10:36:46 +03:00
|
|
|
|
2019-02-01 14:58:26 +03:00
|
|
|
return div;
|
|
|
|
},
|
2019-01-29 10:36:46 +03:00
|
|
|
|
2019-02-01 14:58:26 +03:00
|
|
|
onRemove: function(map) {
|
2019-01-29 10:57:35 +03:00
|
|
|
}
|
2019-02-01 14:58:26 +03:00
|
|
|
});
|