From fb663b5127b84b3a0968926d0211ec412efd33a7 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Thu, 24 Aug 2006 15:07:18 +0000 Subject: [PATCH] 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 --- lib/OpenLayers/Control/MouseDefaults.js | 48 +++++++++++++------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/lib/OpenLayers/Control/MouseDefaults.js b/lib/OpenLayers/Control/MouseDefaults.js index d43f3fb45b..6de8c3cede 100644 --- a/lib/OpenLayers/Control/MouseDefaults.js +++ b/lib/OpenLayers/Control/MouseDefaults.js @@ -166,29 +166,31 @@ OpenLayers.Control.MouseDefaults.prototype = * */ zoomBoxEnd: function(evt) { - if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 || - Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) { - var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); - var end = this.map.getLonLatFromViewPortPx( evt.xy ); - var top = Math.max(start.lat, end.lat); - var bottom = Math.min(start.lat, end.lat); - var left = Math.min(start.lon, end.lon); - var right = Math.max(start.lon, end.lon); - var bounds = new OpenLayers.Bounds(left, bottom, right, top); - var zoom = this.map.getZoomForExtent(bounds); - this.map.setCenter(new OpenLayers.LonLat( - (start.lon + end.lon) / 2, - (start.lat + end.lat) / 2 - ), zoom); - } else { - var end = this.map.getLonLatFromViewPortPx( evt.xy ); - this.map.setCenter(new OpenLayers.LonLat( - (end.lon), - (end.lat) - ), this.map.getZoom() + 1); - } - this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); - this.zoomBox = null; + if (this.mouseDragStart != null) { + if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 || + Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) { + var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); + var end = this.map.getLonLatFromViewPortPx( evt.xy ); + var top = Math.max(start.lat, end.lat); + var bottom = Math.min(start.lat, end.lat); + var left = Math.min(start.lon, end.lon); + var right = Math.max(start.lon, end.lon); + var bounds = new OpenLayers.Bounds(left, bottom, right, top); + var zoom = this.map.getZoomForExtent(bounds); + this.map.setCenter(new OpenLayers.LonLat( + (start.lon + end.lon) / 2, + (start.lat + end.lat) / 2 + ), zoom); + } else { + var end = this.map.getLonLatFromViewPortPx( evt.xy ); + this.map.setCenter(new OpenLayers.LonLat( + (end.lon), + (end.lat) + ), this.map.getZoom() + 1); + } + this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); + this.zoomBox = null; + } },