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.
|
||||
*/
|
||||
extend:function(object) {
|
||||
var bounds = null;
|
||||
if (object) {
|
||||
switch(object.CLASS_NAME) {
|
||||
case "OpenLayers.LonLat":
|
||||
bounds = new OpenLayers.Bounds(object.lon, object.lat,
|
||||
object.lon, object.lat);
|
||||
case "OpenLayers.LonLat":
|
||||
this.extendXY(object.lon, object.lat);
|
||||
break;
|
||||
case "OpenLayers.Geometry.Point":
|
||||
bounds = new OpenLayers.Bounds(object.x, object.y,
|
||||
object.x, object.y);
|
||||
this.extendXY(object.x, object.y);
|
||||
break;
|
||||
|
||||
case "OpenLayers.Bounds":
|
||||
bounds = object;
|
||||
break;
|
||||
}
|
||||
|
||||
if (bounds) {
|
||||
// clear cached center location
|
||||
this.centerLonLat = null;
|
||||
|
||||
if ( (this.left == null) || (bounds.left < this.left)) {
|
||||
this.left = bounds.left;
|
||||
}
|
||||
if ( (this.bottom == null) || (bounds.bottom < this.bottom) ) {
|
||||
this.bottom = bounds.bottom;
|
||||
}
|
||||
if ( (this.right == null) || (bounds.right > this.right) ) {
|
||||
this.right = bounds.right;
|
||||
}
|
||||
if ( (this.top == null) || (bounds.top > this.top) ) {
|
||||
this.top = bounds.top;
|
||||
}
|
||||
case "OpenLayers.Bounds":
|
||||
// clear cached center location
|
||||
this.centerLonLat = null;
|
||||
|
||||
if ( (this.left == null) || (object.left < this.left)) {
|
||||
this.left = object.left;
|
||||
}
|
||||
if ( (this.bottom == null) || (object.bottom < this.bottom) ) {
|
||||
this.bottom = object.bottom;
|
||||
}
|
||||
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