add getLayer() function to Map

git-svn-id: http://svn.openlayers.org/trunk/openlayers@979 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-07-19 14:42:20 +00:00
parent 5855e1cb1f
commit 96d0f62c59
2 changed files with 36 additions and 0 deletions

View File

@@ -233,6 +233,24 @@ OpenLayers.Map.prototype = {
/* */
/********************************************************/
/**
* @param {String} name
*
* @returns The Layer with the corresponding id from the map's
* layer collection, or null if not found.
* @type OpenLayers.Layer
*/
getLayer: function(id) {
var foundLayer = null;
for (var i = 0; i < this.layers.length; i++) {
var layer = this.layers[i];
if (layer.id == id) {
foundLayer = layer;
}
}
return foundLayer;
},
/**
* @param {OpenLayers.Layer} layer
*/