Fix event handling.. no need to detect lastXY
This commit is contained in:
@@ -33,12 +33,6 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
|
||||
element: null,
|
||||
debugElement: null,
|
||||
|
||||
/**
|
||||
* Property: lastXy
|
||||
* {<OpenLayers.Pixel>}
|
||||
*/
|
||||
lastXy: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.UTFGrid
|
||||
* Parameters:
|
||||
@@ -50,7 +44,7 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
|
||||
'stopMove': false,
|
||||
'single': true,
|
||||
'double': false,
|
||||
'pixelTolerance': 0,
|
||||
'pixelTolerance': 4,
|
||||
'stopSingle': false,
|
||||
'stopDouble': false
|
||||
},
|
||||
@@ -115,7 +109,6 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
|
||||
if (options.div) {
|
||||
this.element = OpenLayers.Util.getElement(options.div);
|
||||
}
|
||||
|
||||
this.resetHandler();
|
||||
},
|
||||
|
||||
@@ -123,27 +116,15 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: handleEvent
|
||||
*/
|
||||
handleEvent: function(evt) {
|
||||
var lonLat;
|
||||
|
||||
if (evt == null) {
|
||||
this.reset();
|
||||
return;
|
||||
} else {
|
||||
if (this.lastXy == null ||
|
||||
Math.abs(evt.xy.x - this.lastXy.x) > this.granularity ||
|
||||
Math.abs(evt.xy.y - this.lastXy.y) > this.granularity)
|
||||
{
|
||||
this.lastXy = evt.xy;
|
||||
return;
|
||||
}
|
||||
|
||||
lonLat = this.map.getLonLatFromPixel(evt.xy);
|
||||
if (!lonLat) {
|
||||
// map may not have been properly initialized
|
||||
return;
|
||||
}
|
||||
this.lastXy = evt.xy;
|
||||
}
|
||||
|
||||
var lonLat = this.map.getLonLatFromPixel(evt.xy);
|
||||
if (!lonLat) {
|
||||
return;
|
||||
}
|
||||
|
||||
var layers = this.findLayers();
|
||||
if (layers.length > 0) {
|
||||
@@ -164,8 +145,7 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
|
||||
Math.floor((info.i) / resolution)
|
||||
));
|
||||
attrs = data.data[data.keys[code]];
|
||||
if (attrs)
|
||||
this.callback(attrs);
|
||||
this.callback(attrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,11 +178,11 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
callback: function(attrs) {
|
||||
if (attrs !== null && typeof(attrs) !== 'undefined') {
|
||||
val = "<p>Attributes</p><ul>";
|
||||
val = "<table>";
|
||||
for(var index in attrs) {
|
||||
val += "<li>" + index + " : " + attrs[index] + "</li>";
|
||||
val += "<tr><th>" + index + "</th><td>" + attrs[index] + "</td></tr>";
|
||||
}
|
||||
val += "</ul>";
|
||||
val += "</table>";
|
||||
this.element.innerHTML = val;
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user