[Google Maps Library] Fit map to bounds with padding
Forge component by Labs

The Google Maps API have an update for the fitBounds with padding v3.42.


Is that something that you can add on in the library? I tried doing it manually but won't recognize the parameter.

Many thanks!

Nevermind it works!

For them who are interested I created this function:

    this.fitToBoundsWithPadding = function(mapId, boundsId, topPadding, rightPadding, bottomPadding, leftPadding ) {

        var OSMap = this.getMap(mapId);

        var gMap = OSMap.gMap;

        var gBounds = OSMap.getBounds(boundsId).gBounds;


        gMap.fitBounds(gBounds, {top: topPadding, right: rightPadding, bottom: bottomPadding, left: leftPadding });


Much more cleaner than the fitToBoundsWithOffset function.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.