4

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.

1 Answer 1

8

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

map.getLayersByClass("OpenLayers.Layer.Vector") 
2
  • You're welcome :) Good luck.
    – R.K.
    Commented Nov 11, 2012 at 2:50
  • What is the OpenLayers 3 equivalent for this? Commented May 15, 2017 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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