如何在2个Google地图位置之间实现流畅的动画移动? [英] How can I have a smooth animated move between 2 Google Maps locations?

查看:120
本文介绍了如何在2个Google地图位置之间实现流畅的动画移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google地图中从一个标记点​​击到另一个标记时,如果两个标记都位于初始地图​​视图中,则地图屏幕可以平滑地进行移动,但如果其中一个标记不在屏幕上,则跳转。



我试图设置一个地图,在主地图区域内有几个位置,但有一个位于屏幕外。我在初始地图区域内的较远位置有一个路标图标,我想在点击时平滑滚动到屏幕外的位置(以便更好地了解它的相对位置)。然而,我无法在Maps API中找到任何可以让我这样做的东西。



我可以缩小,移动然后再放大,但这看起来有点刺耳。我是否错过了API中的某些内容,或者有没有人有任何建议?解析方案

不幸的是,我不认为这是可能的(没有来自Google的变更​​)。从 panTo的 v3 API参考


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


这意味着如果变化不小于地图的尺寸​​,过渡将不会流畅动画。其他的泛方法是类似的。



您可以尝试多步移动,但这有点破解,我怀疑结果会很差。 b
$ b

对不起,这不是很有帮助(我有同样的问题)。


When clicking from one marker to another in Google Maps, the map screen animates the move smoothly if both markers are within them initial map view but jumps if one of the markers is off screen.

I'm trying to set up a map which has several locations within the main map area but has one which is 'off screen'. I have a signpost icon to the more distant location within the initial map area which I want to smoothly scroll to the off screen location when clicked (so as to give a better sense of it's relative location). I can't find anything in the Maps API which would let me do this however.

I could zoom out, move and then zoom in again but this looks a bit jarring. Am I missing something in the API, or does anyone have any suggestions?

解决方案

Unfortunately, I don't think this is possible (without a change from Google). From the v3 API reference for panTo:

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.

which implies that if that change is not less than the dimensions of the map, the transition won't be smoothly animated. The other pan methods are similar.

You could try moving in multiple steps but that's a bit of a hack and I suspect the result will be poor.

Sorry that's not very helpful (I have the same problem).

这篇关于如何在2个Google地图位置之间实现流畅的动画移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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