Monday, 4 July 2016

Layer name in OpenLayers 3.0


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.



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




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...