Leaflet-omnivore load multiple KMLs & center

by George   Last Updated January 14, 2018 01:22 AM

I'm new with leaflet-omnivore and looking for the optimal way to load a number of KMLs (each of them containing a polygon) and center the map in their "bounds"

I have tried adding the loaded polygons to a feature group and then try to get the bounds of that in order to center the map. The polygons are showing on the map successfully but the map does not zoom/center

    var polygonGroup = new L.FeatureGroup();            

    // Load kml and add to feature group
    $.each(kmls, function (i, kmlUrl) {
        var polygonLayer = omnivore.kml(kmlUrl);

    // Add group to map

    // Attempt to center map

Related Questions

Need to highlight required area using leaflet

Updated February 18, 2016 08:09 AM

Is it possible to use Leaflet.draw on a map in R?

Updated February 29, 2016 05:09 AM

Leaflet popup disappear or moved over drawn polygon

Updated September 19, 2018 22:22 PM