1
0
forked from MTSR/mapserver

click coordinates

This commit is contained in:
NatureFreshMilk 2019-02-08 14:48:06 +01:00
parent 97d32a5210
commit 10d6e8904d
2 changed files with 29 additions and 10 deletions

View File

@ -4,15 +4,33 @@
var CoordinatesDisplay = L.Control.extend({
onAdd: function(map) {
var div = L.DomUtil.create('div', 'leaflet-bar leaflet-custom-display');
function update(ev){
var latlng = ev.latlng;
div.innerHTML = "X:" + parseInt(latlng.lng) + " Z:" + parseInt(latlng.lat);
var hoverCoord, clickCoord
function updateHover(ev){
hoverCoord = ev.latlng;
update();
}
//TODO: x: 1 z: 2 (selected: x:1 z:3)
map.on('mousemove', update);
map.on('click', update);
map.on('touch', 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;
}
map.on('mousemove', updateHover);
map.on('click', updateClick);
map.on('touch', updateClick);
return div;
},

View File

@ -46,7 +46,7 @@ var AbstractIconOverlay = L.LayerGroup.extend({
reDraw: function(full){
var self = this;
if (this._map.getZoom() < 10) {
if (this.map.getZoom() < 10) {
this.clearLayers();
this.currentObjects = {};
return;
@ -58,8 +58,8 @@ var AbstractIconOverlay = L.LayerGroup.extend({
}
var mapLayer = this.layerMgr.getCurrentLayer()
var min = this._map.getBounds().getSouthWest();
var max = this._map.getBounds().getNorthEast();
var min = this.map.getBounds().getSouthWest();
var max = this.map.getBounds().getNorthEast();
var y1 = parseInt(mapLayer.from/16);
var y2 = parseInt(mapLayer.to/16);
@ -98,6 +98,7 @@ var AbstractIconOverlay = L.LayerGroup.extend({
},
onAdd: function(map) {
this.map = map;
map.on("zoomend", this.onMapMove);
map.on("moveend", this.onMapMove);
this.layerMgr.addListener(this.onLayerChange);