2019-01-29 10:36:46 +03:00
|
|
|
|
2019-06-11 15:16:41 +03:00
|
|
|
export default L.Control.extend({
|
2019-02-01 14:58:26 +03:00
|
|
|
onAdd: function(map) {
|
|
|
|
var div = L.DomUtil.create('div', 'leaflet-bar leaflet-custom-display');
|
2019-02-08 16:48:06 +03:00
|
|
|
|
2019-04-04 11:19:29 +03:00
|
|
|
var hoverCoord, clickCoord;
|
2019-02-08 16:48:06 +03:00
|
|
|
|
|
|
|
function updateHover(ev){
|
|
|
|
hoverCoord = ev.latlng;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateClick(ev){
|
|
|
|
clickCoord = ev.latlng;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
function update(){
|
|
|
|
var html = "";
|
|
|
|
if (hoverCoord)
|
2019-02-08 19:29:50 +03:00
|
|
|
html = html + "X=" + parseInt(hoverCoord.lng) + " Z=" + parseInt(hoverCoord.lat);
|
2019-02-08 16:48:06 +03:00
|
|
|
|
|
|
|
if (clickCoord)
|
2019-02-08 19:29:50 +03:00
|
|
|
html = html + " (marked: X=" + parseInt(clickCoord.lng) + " Z=" + parseInt(clickCoord.lat) + ")";
|
2019-02-08 16:48:06 +03:00
|
|
|
|
|
|
|
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:57:35 +03:00
|
|
|
}
|
2019-02-01 14:58:26 +03:00
|
|
|
});
|