patch for #487 -- dateline wrapping
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3323 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1168,8 +1168,30 @@ OpenLayers.Map.prototype = {
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*/
|
||||
zoomToExtent: function(bounds) {
|
||||
this.setCenter(bounds.getCenterLonLat(),
|
||||
this.getZoomForExtent(bounds));
|
||||
var center = bounds.getCenterLonLat();
|
||||
if (this.baseLayer.wrapDateLine) {
|
||||
var maxExtent = this.getMaxExtent();
|
||||
|
||||
//fix straddling bounds (in the case of a bbox that straddles the
|
||||
// dateline, it's left and right boundaries will appear backwards.
|
||||
// we fix this by allowing a right value that is greater than the
|
||||
// max value at the dateline -- this allows us to pass a valid
|
||||
// bounds to calculate zoom)
|
||||
//
|
||||
bounds = bounds.clone();
|
||||
while (bounds.right < bounds.left) {
|
||||
bounds.right += maxExtent.getWidth();
|
||||
}
|
||||
//if the bounds was straddling (see above), then the center point
|
||||
// we got from it was wrong. So we take our new bounds and ask it
|
||||
// for the center. Because our new bounds is at least partially
|
||||
// outside the bounds of maxExtent, the new calculated center
|
||||
// might also be. We don't want to pass a bad center value to
|
||||
// setCenter, so we have it wrap itself across the date line.
|
||||
//
|
||||
center = bounds.getCenterLonLat().wrapDateLine(maxExtent);
|
||||
}
|
||||
this.setCenter(center, this.getZoomForExtent(bounds));
|
||||
},
|
||||
|
||||
/** Zoom to the full extent and recenter.
|
||||
|
||||
Reference in New Issue
Block a user