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

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

https://developers.google.com/maps/documentation/javascript/reference/map#Map.fitBounds

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

Many thanks!
Kevin

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.