Google Maps v3 - can I ensure smooth panning every time?

后端 未结 6 1442
醉梦人生
醉梦人生 2021-02-01 20:49

My map has several hundred markers within a city. Usually no more than a 20 mile radius. I\'ve read through the documentation and haven\'t found a way to set the init to automat

6条回答
  •  悲哀的现实
    2021-02-01 21:10

    @tato.rodrigo

    I don't have enough reputation to post as an answer so am posting as a reply to Tato here as his plugin works well for me and is exactly what I needed but has a bug (I use it as a dependency so the map variable is passed through the function)

    You need to pass map to function getOptimalZoomOut(latLng, currentZoom) {}

    as you use the map variable inside that function.

    like this: function getOptimalZoomOut(latLng, currentZoom, map) {}

    and later: map.setZoom(getOptimalZoomOut(destLatLng, initialZoom)); pass it in: map.setZoom(getOptimalZoomOut(destLatLng, initialZoom, map)); and maybe another stray one.

提交回复
热议问题