always start the map extent on the right of the dateline
This commit is contained in:
+14
-6
@@ -1940,7 +1940,18 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
var valid = false;
|
var valid = false;
|
||||||
if (lonlat != null) {
|
if (lonlat != null) {
|
||||||
var maxExtent = this.getMaxExtent();
|
var maxExtent = this.getMaxExtent();
|
||||||
valid = maxExtent.containsLonLat(lonlat);
|
valid = maxExtent.containsLonLat(lonlat);
|
||||||
|
if (!valid && this.baseLayer.wrapDateLine) {
|
||||||
|
lonlat = lonlat.clone();
|
||||||
|
var worldWidth = maxExtent.getWidth();
|
||||||
|
while(lonlat.lon > maxExtent.right) {
|
||||||
|
lonlat.lon -= worldWidth;
|
||||||
|
valid = maxExtent.containsLonLat(lonlat);
|
||||||
|
if (valid) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return valid;
|
return valid;
|
||||||
},
|
},
|
||||||
@@ -2254,12 +2265,9 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
}
|
}
|
||||||
//if the bounds was straddling (see above), then the center point
|
//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
|
// 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
|
// for the center.
|
||||||
// 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);
|
center = bounds.getCenterLonLat();
|
||||||
}
|
}
|
||||||
this.setCenter(center, this.getZoomForExtent(bounds, closest));
|
this.setCenter(center, this.getZoomForExtent(bounds, closest));
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user