google maps API 3 zooms out on fitBounds

前端 未结 7 1505
心在旅途
心在旅途 2021-01-11 14:48

I\'ve run into a problem where calling map.fitBounds seems to zoom out. I\'m trying to use the backbone.js router to save the map bounds in the url. I want to be able to boo

7条回答
  •  别那么骄傲
    2021-01-11 15:31

    For people seeing this question in 2018, Google Maps API v3 now supports a second padding argument that specifies the amount of padding to include around the bounds you specify.

    To avoid zooming out, simply just call fitBounds with a padding of 0. For this example it would be map.fitBounds(map.getBounds(), 0)

提交回复
热议问题