Bounds: Simplified extend() method
.. by using the new extendXY() method if the given object is LonLat or a Point.
This commit is contained in:
@@ -355,39 +355,32 @@ OpenLayers.Bounds = OpenLayers.Class({
|
|||||||
* object.
|
* object.
|
||||||
*/
|
*/
|
||||||
extend:function(object) {
|
extend:function(object) {
|
||||||
var bounds = null;
|
|
||||||
if (object) {
|
if (object) {
|
||||||
switch(object.CLASS_NAME) {
|
switch(object.CLASS_NAME) {
|
||||||
case "OpenLayers.LonLat":
|
case "OpenLayers.LonLat":
|
||||||
bounds = new OpenLayers.Bounds(object.lon, object.lat,
|
this.extendXY(object.lon, object.lat);
|
||||||
object.lon, object.lat);
|
|
||||||
break;
|
break;
|
||||||
case "OpenLayers.Geometry.Point":
|
case "OpenLayers.Geometry.Point":
|
||||||
bounds = new OpenLayers.Bounds(object.x, object.y,
|
this.extendXY(object.x, object.y);
|
||||||
object.x, object.y);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "OpenLayers.Bounds":
|
|
||||||
bounds = object;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bounds) {
|
|
||||||
// clear cached center location
|
|
||||||
this.centerLonLat = null;
|
|
||||||
|
|
||||||
if ( (this.left == null) || (bounds.left < this.left)) {
|
case "OpenLayers.Bounds":
|
||||||
this.left = bounds.left;
|
// clear cached center location
|
||||||
}
|
this.centerLonLat = null;
|
||||||
if ( (this.bottom == null) || (bounds.bottom < this.bottom) ) {
|
|
||||||
this.bottom = bounds.bottom;
|
if ( (this.left == null) || (object.left < this.left)) {
|
||||||
}
|
this.left = object.left;
|
||||||
if ( (this.right == null) || (bounds.right > this.right) ) {
|
}
|
||||||
this.right = bounds.right;
|
if ( (this.bottom == null) || (object.bottom < this.bottom) ) {
|
||||||
}
|
this.bottom = object.bottom;
|
||||||
if ( (this.top == null) || (bounds.top > this.top) ) {
|
}
|
||||||
this.top = bounds.top;
|
if ( (this.right == null) || (object.right > this.right) ) {
|
||||||
}
|
this.right = object.right;
|
||||||
|
}
|
||||||
|
if ( (this.top == null) || (object.top > this.top) ) {
|
||||||
|
this.top = object.top;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user