If we turn on the zooming tool, then click on the panzoombar in IE,

because the click drops through (Why god Why?!) we get an error telling
us that evt.xy doesn't exist, so we wrap it in an if statement which
protects us. (Deliver us, o if statement, from IEvil...) 


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1358 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-08-24 15:07:18 +00:00
parent 1f9cb14069
commit fb663b5127
+25 -23
View File
@@ -166,29 +166,31 @@ OpenLayers.Control.MouseDefaults.prototype =
* *
*/ */
zoomBoxEnd: function(evt) { zoomBoxEnd: function(evt) {
if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 || if (this.mouseDragStart != null) {
Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) { if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
var end = this.map.getLonLatFromViewPortPx( evt.xy ); var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var top = Math.max(start.lat, end.lat); var end = this.map.getLonLatFromViewPortPx( evt.xy );
var bottom = Math.min(start.lat, end.lat); var top = Math.max(start.lat, end.lat);
var left = Math.min(start.lon, end.lon); var bottom = Math.min(start.lat, end.lat);
var right = Math.max(start.lon, end.lon); var left = Math.min(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top); var right = Math.max(start.lon, end.lon);
var zoom = this.map.getZoomForExtent(bounds); var bounds = new OpenLayers.Bounds(left, bottom, right, top);
this.map.setCenter(new OpenLayers.LonLat( var zoom = this.map.getZoomForExtent(bounds);
(start.lon + end.lon) / 2, this.map.setCenter(new OpenLayers.LonLat(
(start.lat + end.lat) / 2 (start.lon + end.lon) / 2,
), zoom); (start.lat + end.lat) / 2
} else { ), zoom);
var end = this.map.getLonLatFromViewPortPx( evt.xy ); } else {
this.map.setCenter(new OpenLayers.LonLat( var end = this.map.getLonLatFromViewPortPx( evt.xy );
(end.lon), this.map.setCenter(new OpenLayers.LonLat(
(end.lat) (end.lon),
), this.map.getZoom() + 1); (end.lat)
} ), this.map.getZoom() + 1);
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); }
this.zoomBox = null; this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
}
}, },