Allow use of array for bounds.

This commit is contained in:
tschaub
2011-10-26 15:40:40 -06:00
parent 75a1a8e119
commit 98ee7167c4
4 changed files with 52 additions and 3 deletions
+6
View File
@@ -67,6 +67,12 @@ OpenLayers.Bounds = OpenLayers.Class({
* top - {Number} The top bounds.
*/
initialize: function(left, bottom, right, top) {
if (OpenLayers.Util.isArray(left)) {
top = left[3];
right = left[2];
bottom = left[1];
left = left[0];
}
if (left != null) {
this.left = OpenLayers.Util.toFloat(left);
}
+11
View File
@@ -478,6 +478,14 @@ OpenLayers.Map = OpenLayers.Class({
// now override default options
OpenLayers.Util.extend(this, options);
// allow extents to be arrays
if (this.maxExtent && !(this.maxExtent instanceof OpenLayers.Bounds)) {
this.maxExtent = new OpenLayers.Bounds(this.maxExtent);
}
if (this.restrictedExtent && !(this.restrictedExtent instanceof OpenLayers.Bounds)) {
this.restrictedExtent = new OpenLayers.Bounds(this.restrictedExtent);
}
// initialize layers array
this.layers = [];
@@ -2211,6 +2219,9 @@ OpenLayers.Map = OpenLayers.Class({
*
*/
zoomToExtent: function(bounds, closest) {
if (!(bounds instanceof OpenLayers.Bounds)) {
bounds = new OpenLayers.Bounds(bounds);
}
var center = bounds.getCenterLonLat();
if (this.baseLayer.wrapDateLine) {
var maxExtent = this.getMaxExtent();