From c5fc30cf9770c9af0d924fc9a5b9a3db0213537a Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 1 Jun 2006 00:33:15 +0000 Subject: [PATCH] adding OpenLayers.Bounds.fromArray() function and adaptor for fromString() git-svn-id: http://svn.openlayers.org/trunk/openlayers@486 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Util.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 7b37e3761e..6987e0e062 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -470,12 +470,25 @@ OpenLayers.Bounds.prototype = { */ OpenLayers.Bounds.fromString = function(str) { var bounds = str.split(","); - return new OpenLayers.Bounds(parseFloat(bounds[0]), - parseFloat(bounds[1]), - parseFloat(bounds[2]), - parseFloat(bounds[3])); + return OpenLayers.Bounds.fromArray(bounds); }; +/** Alternative constructor that builds a new OpenLayers.Bounds +* from an array +* +* @constructor +* +* @param {Array} bbox Array of bounds values (ex. [5,42,10,45]) +* +* @returns New OpenLayers.Bounds object built from the passed-in Array. +* @type OpenLayers.Bounds +*/ +OpenLayers.Bounds.fromArray = function(bbox) { + return new OpenLayers.Bounds(parseFloat(bbox[0]), + parseFloat(bbox[1]), + parseFloat(bbox[2]), + parseFloat(bbox[3])); +}; /** * @param {String} quadrant