How can I have a smooth animated move between 2 Google Maps locations?

前端 未结 3 1874
梦谈多话
梦谈多话 2021-01-31 17:41

When clicking from one marker to another in Google Maps, the map screen animates the move smoothly if both markers are within them initial map view but jumps if one of the marke

3条回答
  •  庸人自扰
    2021-01-31 18:35

    Unfortunately, I don't think this is possible (without a change from Google). From the v3 API reference for panTo:

    Changes the center of the map to the given LatLng. If the change is less than both the width and height of the map, the transition will be smoothly animated.

    which implies that if that change is not less than the dimensions of the map, the transition won't be smoothly animated. The other pan methods are similar.

    You could try moving in multiple steps but that's a bit of a hack and I suspect the result will be poor.

    Sorry that's not very helpful (I have the same problem).

提交回复
热议问题