就像标题所说的那样。我正在寻找解决方案,但没有找到任何可以引导我找到正确文档或文章的内容。
如果您有任何想法或可以指出我可以使用的可能解决方案,我们将不胜感激。
谢谢
就像标题所说的那样。我正在寻找解决方案,但没有找到任何可以引导我找到正确文档或文章的内容。
如果您有任何想法或可以指出我可以使用的可能解决方案,我们将不胜感激。
谢谢
你可以自己这样做:
setInterval
设置要定期运行的功能。panBy
Google 地图对象以“旋转”它一点。这应该会给你一个简单的动画来做你想做的事。您当然想要调整您给予的时间间隔setInterval
以获得感觉平滑的东西。你应该有这样的东西:
// Create your map and leave it in the "map" variable.
setInterval(function() {
map.panBy(x, 0);
}, n);
选择合适的x
和n
价值观取决于你。
接受的答案是好的,但有点过时了。而不是window.setInterval
你应该使用window.requestAnimationFrame
. 这将为您提供更流畅的动画。
可以在此处找到一个简单的示例(不是我的示例) ,但它的要点如下所示:
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()
})