Is there a method or property in javascript using the Openlayers (3 or) 4 library which I can use to verify if a given layer is a layer group?

2 Answers 2


You can test your layer to see if it's an instance of a layer group:

if (myLayer instanceof ol.layer.Group) {
    alert("It's a group!");

Check out this leaflet plugin:


checkIn() methods may return added layer groups.

  • i'd have to use leaflet instead of the OL library, right?
    – tony gil
    Jul 21, 2017 at 20:17

Your Answer

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

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