diff --git a/examples/spherical-mercator.html b/examples/spherical-mercator.html
index fd6a3250da..88e207f27a 100644
--- a/examples/spherical-mercator.html
+++ b/examples/spherical-mercator.html
@@ -41,12 +41,12 @@
var map = new OpenLayers.Map({
div: "map",
- projection: new OpenLayers.Projection("EPSG:900913"),
- displayProjection: new OpenLayers.Projection("EPSG:4326"),
+ projection: "EPSG:900913",
+ displayProjection: "EPSG:4326",
units: "m",
numZoomLevels: 18,
maxResolution: 156543.0339,
- maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508),
+ maxExtent: [-20037508, -20037508, 20037508, 20037508],
});
// create Google Mercator layers
diff --git a/lib/OpenLayers/BaseTypes/Bounds.js b/lib/OpenLayers/BaseTypes/Bounds.js
index 5935ccbe1a..9eefcc1831 100644
--- a/lib/OpenLayers/BaseTypes/Bounds.js
+++ b/lib/OpenLayers/BaseTypes/Bounds.js
@@ -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);
}
diff --git a/lib/OpenLayers/BaseTypes/LonLat.js b/lib/OpenLayers/BaseTypes/LonLat.js
index 70c883d4f1..77206f4217 100644
--- a/lib/OpenLayers/BaseTypes/LonLat.js
+++ b/lib/OpenLayers/BaseTypes/LonLat.js
@@ -38,6 +38,10 @@ OpenLayers.LonLat = OpenLayers.Class({
* it will be the y coordinate of the map location in your map units.
*/
initialize: function(lon, lat) {
+ if (OpenLayers.Util.isArray(lon)) {
+ lat = lon[1];
+ lon = lon[0];
+ }
this.lon = OpenLayers.Util.toFloat(lon);
this.lat = OpenLayers.Util.toFloat(lat);
},
diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js
index ab115223ca..fcc919833f 100644
--- a/lib/OpenLayers/Layer.js
+++ b/lib/OpenLayers/Layer.js
@@ -464,6 +464,16 @@ OpenLayers.Layer = OpenLayers.Class({
if (this.options == null) {
this.options = {};
}
+
+ // allow array for extents
+ if (newOptions) {
+ if (newOptions.maxExtent && !(newOptions.maxExtent instanceof OpenLayers.Bounds)) {
+ newOptions.maxExtent = new OpenLayers.Bounds(newOptions.maxExtent);
+ }
+ if (newOptions.minExtent && !(newOptions.minExtent instanceof OpenLayers.Bounds)) {
+ newOptions.minExtent = new OpenLayers.Bounds(newOptions.minExtent);
+ }
+ }
// update our copy for clone
OpenLayers.Util.extend(this.options, newOptions);
diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js
index 8ce24e374d..33daa3a66c 100644
--- a/lib/OpenLayers/Map.js
+++ b/lib/OpenLayers/Map.js
@@ -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 = [];
@@ -1703,6 +1711,9 @@ OpenLayers.Map = OpenLayers.Class({
* options - {Object}
*/
moveTo: function(lonlat, zoom, options) {
+ if (!(lonlat instanceof OpenLayers.LonLat)) {
+ lonlat = new OpenLayers.LonLat(lonlat);
+ }
if (!options) {
options = {};
}
@@ -2208,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();
diff --git a/lib/OpenLayers/Projection.js b/lib/OpenLayers/Projection.js
index 7e652ba27d..f30f679081 100644
--- a/lib/OpenLayers/Projection.js
+++ b/lib/OpenLayers/Projection.js
@@ -101,6 +101,9 @@ OpenLayers.Projection = OpenLayers.Class({
equals: function(projection) {
var p = projection, equals = false;
if (p) {
+ if (!(p instanceof OpenLayers.Projection)) {
+ p = new OpenLayers.Projection(p);
+ }
if (window.Proj4js && this.proj.defData && p.proj.defData) {
equals = this.proj.defData.replace(this.titleRegEx, "") ==
p.proj.defData.replace(this.titleRegEx, "");
@@ -183,12 +186,19 @@ OpenLayers.Projection.addTransform = function(from, to, method) {
* point - {object} A transformed coordinate. The original point is modified.
*/
OpenLayers.Projection.transform = function(point, source, dest) {
- if (source.proj && dest.proj) {
- point = Proj4js.transform(source.proj, dest.proj, point);
- } else if (source && dest &&
- OpenLayers.Projection.transforms[source.getCode()] &&
- OpenLayers.Projection.transforms[source.getCode()][dest.getCode()]) {
- OpenLayers.Projection.transforms[source.getCode()][dest.getCode()](point);
+ if (source && dest) {
+ if (!(source instanceof OpenLayers.Projection)) {
+ source = new OpenLayers.Projection(source);
+ }
+ if (!(dest instanceof OpenLayers.Projection)) {
+ dest = new OpenLayers.Projection(dest);
+ }
+ if (source.proj && dest.proj) {
+ point = Proj4js.transform(source.proj, dest.proj, point);
+ } else if (OpenLayers.Projection.transforms[source.getCode()] &&
+ OpenLayers.Projection.transforms[source.getCode()][dest.getCode()]) {
+ OpenLayers.Projection.transforms[source.getCode()][dest.getCode()](point);
+ }
}
return point;
};
diff --git a/tests/BaseTypes/Bounds.html b/tests/BaseTypes/Bounds.html
index b436005d1c..a1497cf6da 100644
--- a/tests/BaseTypes/Bounds.html
+++ b/tests/BaseTypes/Bounds.html
@@ -4,7 +4,7 @@