1
0
forked from MTSR/mapserver
mapserver/public/js/map/CoordinatesDisplay.js

36 lines
837 B
JavaScript
Raw Permalink Normal View History

2019-01-29 08:36:46 +01:00
2019-06-11 14:16:41 +02:00
export default L.Control.extend({
2019-02-01 12:58:26 +01:00
onAdd: function(map) {
var div = L.DomUtil.create('div', 'leaflet-bar leaflet-custom-display');
2019-02-08 14:48:06 +01:00
2019-04-04 10:19:29 +02:00
var hoverCoord, clickCoord;
2019-02-08 14:48:06 +01:00
function updateHover(ev){
hoverCoord = ev.latlng;
update();
}
function updateClick(ev){
clickCoord = ev.latlng;
update();
}
function update(){
var html = "";
if (hoverCoord)
2019-02-08 17:29:50 +01:00
html = html + "X=" + parseInt(hoverCoord.lng) + " Z=" + parseInt(hoverCoord.lat);
2019-02-08 14:48:06 +01:00
if (clickCoord)
2019-02-08 17:29:50 +01:00
html = html + " (marked: X=" + parseInt(clickCoord.lng) + " Z=" + parseInt(clickCoord.lat) + ")";
2019-02-08 14:48:06 +01:00
div.innerHTML = html;
2019-02-01 12:58:26 +01:00
}
2019-01-29 08:36:46 +01:00
2019-02-08 14:48:06 +01:00
map.on('mousemove', updateHover);
map.on('click', updateClick);
map.on('touch', updateClick);
2019-01-29 08:36:46 +01:00
2019-02-01 12:58:26 +01:00
return div;
2019-01-29 08:57:35 +01:00
}
2019-02-01 12:58:26 +01:00
});