Search code examples
javascriptjquerygoogle-mapsmapspanning

Can Google Maps be set to a slow constant pan? Like a globe revolution?


Just what the title says. I am searching for a solution but I have not found anything that has guided me to the correct documentation or articles.

If you have any ideas or can point me to a possible solution I can work with, it would be greatly appreciated.

Thanks


Solution

  • You can do this yourself like this:

    • Use setInterval to set up a function to be run periodically.
    • The function would call panBy on the Google map object to "rotate" it a bit.

    That should give you a simple animation that does what you want. You'd want to adjust the time interval that you give to setInterval to get something that feels smooth of course. You should have something like this:

    // Create your map and leave it in the "map" variable.
    setInterval(function() {
        map.panBy(x, 0);
    }, n);
    

    Choosing appropriate x and n values is up to you.