add method OpenLayers.LonLat.fromArray for API-consistency. r=bartvde, p=me (closes #3443)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12197 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -190,3 +190,22 @@ OpenLayers.LonLat.fromString = function(str) {
|
||||
var pair = str.split(",");
|
||||
return new OpenLayers.LonLat(pair[0], pair[1]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: fromArray
|
||||
* Alternative constructor that builds a new <OpenLayers.LonLat> from an
|
||||
* array of two numbers that represent lon- and lat-values.
|
||||
*
|
||||
* Parameters:
|
||||
* arr - {Array(Float)} Array of lon/lat values (e.g. [5,-42])
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.LonLat>} New <OpenLayers.LonLat> object built from the
|
||||
* passed-in array.
|
||||
*/
|
||||
OpenLayers.LonLat.fromArray = function(arr) {
|
||||
var gotArr = OpenLayers.Util.isArray(arr),
|
||||
lon = gotArr && arr[0],
|
||||
lat = gotArr && arr[1];
|
||||
return new OpenLayers.LonLat(lon, lat);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user