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
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user