The accepted answer is ok, but a little outdated. Instead of window.setInterval
you shoud use window.requestAnimationFrame
. This will give you a smoother animation.
A simple example (not from me) can be found here, but the gist of it looks something like this:
var map = new google.maps.Map(document.getElementById('my-map'), mapOptions)
function animate () {
map.panBy(2.5 / 2, 1.3 / 2)
window.requestAnimationFrame(function () {
animate()
})
}
// eslint-disable-next-line
google.maps.event.addListenerOnce(map, "tilesLoaded", function () {
window.requestAnimationFrame(function () {
animate()
})
})
window.requestAnimationFrame(function () {
animate()
})