From 948406b5b534e857c903e75e0a9d75f05afb4cbd Mon Sep 17 00:00:00 2001 From: euzuro Date: Fri, 16 Feb 2007 16:45:26 +0000 Subject: [PATCH] patch for #486 -- more error prevention. thanks very much to bart for finding these :-) git-svn-id: http://svn.openlayers.org/trunk/openlayers@2228 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/OverviewMap.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 20b70eb4d0..5786882ea7 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -428,12 +428,14 @@ OpenLayers.Control.OverviewMap.prototype = // The base layer for overview map needs to be in the same projection // as the base layer for the main map. This should be made more robust. if(this.map.units != 'degrees') { - if(this.map.getProjection() != this.ovmap.getProjection()) { + if(this.ovmap.getProjection() && (this.map.getProjection() != this.ovmap.getProjection())) { alert('The overview map only works when it is in the same projection as the main map'); } } var pxBounds = this.getRectBoundsFromMapBounds(this.map.getExtent()); - this.setRectPxBounds(pxBounds); + if (pxBounds) { + this.setRectPxBounds(pxBounds); + } }, /** @@ -489,8 +491,12 @@ OpenLayers.Control.OverviewMap.prototype = lonLatBounds.top); var leftBottomPx = this.getOverviewPxFromLonLat(leftBottomLonLat); var rightTopPx = this.getOverviewPxFromLonLat(rightTopLonLat); - return new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y, - rightTopPx.x, rightTopPx.y); + var bounds = null; + if (leftBottomPx && rightTopPx) { + bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y, + rightTopPx.x, rightTopPx.y); + } + return bounds; }, /** @@ -540,10 +546,13 @@ OpenLayers.Control.OverviewMap.prototype = getOverviewPxFromLonLat: function(lonlat) { var res = this.ovmap.getResolution(); var extent = this.ovmap.getExtent(); - return new OpenLayers.Pixel( - Math.round(1/res * (lonlat.lon - extent.left)), - Math.round(1/res * (extent.top - lonlat.lat)) - ); + var px = null; + if (extent) { + px = new OpenLayers.Pixel( + Math.round(1/res * (lonlat.lon - extent.left)), + Math.round(1/res * (extent.top - lonlat.lat))); + } + return px; }, /** @final @type String */