mapserver/server/static/js/CoordinatesDisplay.js

41 lines
915 B
JavaScript
Raw Normal View History

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)
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: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
});