forked from MTSR/mapserver
click coordinates
This commit is contained in:
parent
97d32a5210
commit
10d6e8904d
@ -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;
|
||||
},
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user