谷歌地图v3 - 我可以确保每次平滑的平移吗? [英] Google Maps v3 - can I ensure smooth panning every time?

查看:132
本文介绍了谷歌地图v3 - 我可以确保每次平滑的平移吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的地图在一个城市内有数百个标记。通常不超过20英里半径。
我读过文档,并没有找到一种方法来设置init在每个标记之间自动平移,无论距离如何。
默认行为是在平移时平移,如果很远则跳转。
我明白他们为什么会这样做,因为地图不会在选定的缩放级别加载全世界,并且如果距离太大,它可能会搞砸。不过,我认为它可以处理20英里的范围,并且投诉最少。

如果有人有任何想法,我很乐意听到他们的意见。
谢谢

解决方案

平滑平移的阈值并不取决于当前中心与新目标之间的距离。这取决于是否需要整页滚动(水平和垂直)或不是:

API参考资料


panTo(latLng:LatLng)



将地图的中心更改为给定的LatLng。如果变化小于地图的宽度和高度,则过渡将平滑地进行。

因此,只要你缩小了,使得你的视口的高度和宽度都是20英里,你应该保证在20英里以内的距离平滑地平移。


My map has several hundred markers within a city. Usually no more than a 20 mile radius. I've read through the documentation and haven't found a way to set the init to automatically pan between every marker, no matter the distance. The default behavior is to pan if close, jump if far. I understand why they would do this since the map doesn't load the whole world at the selected zoom level and it could screw up if the distance was too great. However, I think it could handle 20 mile radius with minimal complaints.

If anyone has any ideas, I'd love to hear them. Thanks

解决方案

The threshold of the smooth panning does not depend on the distance between the current center and the new target. It depends on whether the change will require a full page scroll (horizontally and vertically) or not:

Quoting from the API Reference:

panTo(latLng:LatLng)

Changes the center of the map to the given LatLng. If the change is less than both the width and height of the map, the transition will be smoothly animated.

Therefore, as long as you are zoomed out such that your viewport is 20 miles in height and width, you should be guaranteed smooth panning for distances under 20 miles.

这篇关于谷歌地图v3 - 我可以确保每次平滑的平移吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆