减慢谷歌 panTo 功能
我有一张地图,当标记被放置在地图上时,它可以在地图周围从一个点平移到另一个点。我遇到的问题是平移太快。有什么办法可以减慢 panTo 功能的速度吗?
谢谢, 克里斯
I have a map that pans from point to point around a map as markers are dropped on the map. The issue I'm having is that the panning is too fast. Is there any way to slow down the panTo function?
Thanks,
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
遗憾的是,不,您无法更改 panTo 动画的速度。
该函数仅接受一个 latlng 参数。详细信息请参见:http://code.google.com/apis/地图/documentation/javascript/reference.html#Map
Sadly, no, you cannot change the speed of the panTo animation.
The function only takes a single latlng argument. Details here: http://code.google.com/apis/maps/documentation/javascript/reference.html#Map
我编写了自己的 panTo 实现。使用“EasingAnimator”类。
现在您可以控制一切,包括持续时间、步骤,当然还有缓动功能。这里有一些很好的例子http://easings.net/。现在您可以像这样使用它:
在这里您可以找到其工作原理的现场演示
http://codepen.io/ErDmKo/pen/Jdpmzv
I write my own implementation of panTo. Using class "EasingAnimator".
Now you can control everything including duration, steps and of course the easing function. Here are some nice examples of it http://easings.net/. And now you can use it some like this:
Here you can find live demo of how it works
http://codepen.io/ErDmKo/pen/Jdpmzv
我编写了一个函数来使用 Google Maps API v3 实现“慢摇”。它使用小平移步骤以及之前的答案,但我认为实现更简单一些。您可以对 f_timeout() 使用缓动函数。
参数
map:您的 google.maps.Map 对象
endPosition:所需的平移位置,google.maps.LatLng
n_intervals:平移间隔数,越多过渡越平滑,但性能越差
T_msec:慢摇镜头完成的总时间间隔(毫秒)
I wrote a function to implement a "slow pan" with Google Maps API v3. It uses small pan steps as well as the previous answer, though I think the implementation is a bit simpler. You may use an easing function for f_timeout().
Parameters
map: your google.maps.Map object
endPosition: desired location to pan to, google.maps.LatLng
n_intervals: number of pan intervals, the more the smoother the transition but the less performant
T_msec: the total time interval for the slow pan to complete (milliseconds)