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.


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

  • You're welcome :) Good luck. – R.K. Nov 11 '12 at 2:50
  • What is the OpenLayers 3 equivalent for this? – Steve Staple May 15 '17 at 7:41

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.