For your information, there's currently a method (getLayersByName [1]) that is already written and might match your needs.
http://dev.openlayers.org/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.getLayersByName Regards, Pierre On Wed, Apr 2, 2008 at 6:57 PM, Linda Rawson <[EMAIL PROTECTED]> wrote: > I have several custom enhancements I have made to the source code. With the > onset of a new release I would like to put these in a separate file and > "override" the code that is in the release. For instance I might want to > add the following function, just an example, it might already be in there to > Map.js > > getLayerByName: function(name) { > var foundLayer = null; > for (var i = 0; i < this.layers.length; i++) { > var layer = this.layers[i]; > if (layer.name == name) { > foundLayer = layer; > } > } > return foundLayer; > }, > > Would I do something like the following in a .js file to be called after > Openlayers.js? > > Map.prototype.getLayerByName=function(name) { > var foundLayer = null; > for (var i = 0; i < this.layers.length; i++) { > var layer = this.layers[i]; > if (layer.name == name) { > foundLayer = layer; > } > } > return foundLayer; > } > > How do you do this? > -- > Linda Rawson > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users > > _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
