How to zoom in smoothly on a marker in Google Maps?

后端 未结 6 1818
孤独总比滥情好
孤独总比滥情好 2020-12-22 22:28

I\'d like to be able to zoom in smoothly on a marker in Google Maps. If one just sets the zoom on double click, the map is suddenly on that zoom level, without any smooth tr

6条回答
  •  失恋的感觉
    2020-12-22 23:09

    You could try to use a setInterval to zoom in one level at a time, and clear it when you reach your desired level.

    The problem with this is that the interval that will make it work is entirely dependent on the cpu and bandwidth of the users machine (how fast can it load and render the new set of image tiles).

    Tbh, i'm not sure it can be done so that it will work great in every situation, but a small interval between zoom levels might help a bit.

    A few things to keep in mind tho:

    1. this will put a lot more stress on the users cpu and bandwidth than going directly to the chosen zoomlevel
    2. the user will have to wait until this is done to start interacting with the map, which could easily become a very bad user experience.

    Those two and probably other reasons are why google didn't build the kind of zoom you wish into maps in the first place - because it's a bad idea...

提交回复
热议问题