google-mapsgoogle-maps-api-3fitbounds

Does Google Maps fitBounds() regenerate the map?


I always used to work with panTo instead of setCenter to recenter a Google map because I read somewhere that using panTo is not being counted as a new daily usage of map (to consider the daily limitation of using google map on my website) but I don't remember where I read that.

Now I am using fitBounds and I am not sure if this method regenerates a new map too?

How can I find out which methods (e.g. setZoom or fitBounds) produce a new map? Does fitBounds?


Solution

  • Your understanding is correct. The fitBounds() method does not create a new map, it just sets the viewport to contain the given map bounds.

    Google's documentation states the following:

    SKU: Dynamic Maps

    A web page or application that displays a map using the Maps JavaScript API. A map is created with the google.maps.Map() class.

    User interactions with the map, such as panning, zooming, or switching map layers, do not generate additional map loads.

    You may also refer to this FAQ to understand how map loads are counted.

    Hope this answers your concern.