requirejs(["mapboxgl"], function(mapboxgl) {
    var map = window.__jm_maps["{{uuid}}"];

    var run = function() {
        var source = map.getSource("{{source_uuid}}");
        var geojson = source._data;
        var coordinates = geojson.features[0].geometry.coordinates[0];
        if (coordinates[0] instanceof Array) {
            coordinates = coordinates[0];
        }
        var bounds = new mapboxgl.LngLatBounds(coordinates, coordinates);
        geojson.features.forEach(function(feature) {
            coordinates = feature.geometry.coordinates;
            if (coordinates[0] instanceof Array) {
                coordinates = coordinates[0];
            }
            bounds = coordinates.reduce(function(bounds, coord) {
                return bounds.extend(coord);
            }, bounds);
        });

        map.fitBounds(bounds, {
            padding: {{padding}}
        });
    }

    if (map._loaded) {
        run();
    } else {
        map.on("load", run);
    }
});

@@ -91,19 +91,26 @@
     var 
-run
+findBounds
  = funct
@@ -117,262 +117,244 @@
 ion(
-) %7B%0A        var source = map.getSource(%22%7B%7Bsource_uuid%7D%7D%22);%0A        var geojson = source._data;%0A        var coordinates = geojson.features%5B0%5D.geometry.coordinates%5B0%5D;%0A        if (coordinates%5B0%5D instanceof Array) %7B%0A            coordinates = coordinates%5B0%5D;
+bounds, coordinates) %7B%0A        if (coordinates%5B0%5D instanceof Array) %7B%0A            coordinates.forEach(function(c) %7B%0A                bounds = findBounds(bounds, c);%0A            %7D);%0A        %7D else %7B%0A            if (bounds === undefined) %7B
 %0A   
@@ -358,26 +358,24 @@
         
-%7D%0A
         
 var boun
@@ -366,20 +366,16 @@
         
-var 
 bounds =
@@ -440,96 +440,60 @@
     
-geojson.features.forEach(function(feature) %7B%0A            coordinates = feature.geometry.
+    %7D else %7B%0A                bounds = bounds.extend(
 coor
@@ -499,24 +499,25 @@
 rdinates
+)
 ;%0A      
       if
@@ -512,112 +512,173 @@
     
+   
+   %7D%0A
       
-if (coordinates%5B0%5D instanceof Array) %7B%0A                coordinates = coordinates%5B0%5D;%0A            %7D
+  %7D%0A        return bounds;%0A    %7D%0A%0A    var run = function() %7B%0A        var source = map.getSource(%22%7B%7Bsource_uuid%7D%7D%22);%0A        var geojson = source._data;
 %0A   
@@ -674,35 +674,35 @@
 ._data;%0A        
-   
+var
  bounds = coordi
@@ -699,118 +699,139 @@
 s = 
-coordinates.reduce(function(bounds, coord) %7B%0A                return bounds.extend(coord);%0A            %7D, bound
+undefined;%0A        geojson.features.forEach(function(feature) %7B%0A            bounds = findBounds(bounds, feature.geometry.coordinate
 s);%0A

Support for any type of geometry in fit_source.