5

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.

11

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 with layer.set('name', 'foobar'))

 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.