12

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?

12

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

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

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.