Wednesday, 2 December 2015

How to get all Vector layers from OpenLayers map?


OpenLayers.Map object exposes a method call getLayersByClass. How do I use this method to retrieve all of the Vector layers from the map?


I tried map.getLayersByClass("Vector") but this returned an empty array.



Answer



The class should be OpenLayers.Layer.Vector not Vector. So your code should be:


map.getLayersByClass("OpenLayers.Layer.Vector") 

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...