I'm looping through all the layers in my map using
map.getLayers().forEach(function(layer, i) {
...
});
I'd like to get the name of each layer but I haven't been able to find anything in the examples or the documentation. Any pointers?
I'm using OpenLayers 3.0.0.
Best Answer
name
is just a property you can set on your layer. All constructor options which are not part of the API [1] are treated as property[2].You can later get it with
layer.get('name')
(& set it withlayer.set('name', 'foobar')
)property
ofol.Object
http://openlayers.org/en/v3.0.0/apidoc/ol.Object.html