Only shift extents that cross once.

This commit is contained in:
tschaub
2011-09-29 19:46:00 -06:00
parent d291b970a4
commit 5925cb12d7
+8 -5
View File
@@ -652,21 +652,24 @@ OpenLayers.Bounds = OpenLayers.Class({
if (maxExtent) { if (maxExtent) {
var width = maxExtent.getWidth(); var width = maxExtent.getWidth();
var newRight = newBounds.right - rightTolerance;
var newLeft = newBounds.left + leftTolerance;
//shift right? //shift right?
while (newBounds.left < maxExtent.left && while (newBounds.left < maxExtent.left &&
newBounds.right - rightTolerance <= maxExtent.left ) { newRight <= maxExtent.left ) {
newBounds = newBounds.add(width, 0); newBounds = newBounds.add(width, 0);
} }
//shift left? //shift left?
while (newBounds.left + leftTolerance >= maxExtent.right && while (newLeft >= maxExtent.right &&
newBounds.right > maxExtent.right ) { newBounds.right > maxExtent.right ) {
newBounds = newBounds.add(-width, 0); newBounds = newBounds.add(-width, 0);
} }
// crosses right? force left // crosses right only? force left
if (newBounds.left + leftTolerance < maxExtent.right && if (newLeft < maxExtent.right && newLeft > maxExtent.left &&
newBounds.right - rightTolerance > maxExtent.right) { newRight > maxExtent.right) {
newBounds = newBounds.add(-width, 0); newBounds = newBounds.add(-width, 0);
} }
} }