I have added multiple geoJSON layers to my map by first adding them to a LayerGroup and then adding the layerGroup to the map.

Now I want to call fitBounds on the map with the combined bounds of all the layers, the problem is that layerGroup does not have the method getBounds

what can I do?

1 Answer 1


Use a L.FeatureGroup instead of a L.LayerGroup, as the former does implement L.FeatureGroup.getBounds().

  • 1
    Thanks, I did that. I should have gone for it from the start. featureGroup makes LayerGroup unnecessary in my opinion.
    – fccoelho
    Commented Feb 15, 2016 at 8:14

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.