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 */