18

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?

fccoelho
  • 1,237
  • 5
  • 13
  • 22

1 Answers1

28

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

IvanSanchez
  • 10,206
  • 2
  • 19
  • 35
  • 1
    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 08:14