在谷歌地图V2动画标记 [英] Animating markers on Google Maps V2

查看:187
本文介绍了在谷歌地图V2动画标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是使用第2版API要设置动画古尔地图标记的最佳方法是什么?

What is the best way to animate markers on Goole Maps using v2 Api?

我的工作在地图中心的游戏,我跟踪人的位置,并显示他们在地图上对方看。随人动,我想从他目前的一个标志动画,以他的最新情况。每个人都有一个方向,所以我需要相应地旋转标志。

I am working on a map centered game where I track locations of people and display them on the map for each other to see. As people move, I want to animate a marker from his current to his latest position. Every person has a direction, so I need to rotate marker appropriately.

什么是使用新的谷歌地图API来做到这一点的最好方法是什么?

What is the best way to do it using the new Google Maps API?

推荐答案

一些谷歌的工程师们提供了一个很好的演示视频用一些优雅的样本code有关如何从起点动画标记为终点,所有各种版本的Andr​​oid的:

Some Google engineers have provided a nice demo video with some elegant sample code about how to animate markers from a starting point to an ending point, for all various versions of Android:

相关code是在这里:

The relevant code is here:

https://gist.github.com/broady/6314689

和它的所有的动作一个很好的演示视频。

And a nice demo video of all of it in action.

http://youtu.be/WKfZsCKSXVQ

老店德preCATED回答以下

在文档中,需提到的是标记图标不能被改变:

In the documentation, it is mentioned that Marker Icons cannot be changed:

图标

就是显示标记的位图。如果图标未设置,则显示默认图标。您可以指定使用defaultMarker(浮点)的默认图标的另一种色彩。 您不能一旦你创建了标志更改图标。

A bitmap that's displayed for the marker. If the icon is left unset, a default icon is displayed. You can specify an alternative coloring of the default icon using defaultMarker(float). You can't change the icon once you've created the marker.

谷歌地图API V2文档

你将不得不跟踪的特异性标志物,可能会使用类似的是,这里所描述的方法:<一href="http://stackoverflow.com/questions/14310280/how-to-link-google-maps-android-api-v2-marker-to-an-object/14324081#14324081">Link一个标记为对象,然后找出哪些指标需要更新。呼叫卸下摆臂()上的标记,然后创建取决于方向旋转的形象,你想,创建一个新的标记与图像,并添加新的标记来在地图上。

You're going to have to keep track of specific markers, perhaps using a method similar to that described here: Link a Marker to an Object, then figure out which marker you need to update. Call .remove() on the marker, then create a rotated image depending on the "direction" you want, create a new Marker with that image, and add the new Marker to the map.

您不必清除的地图,只需删除你要修改的标记,创建一个新的,然后重新添加到地图中。

You do not need to "clear" the map, simply remove the marker you want to modify, create a new one, then add it back to the map.

不幸的是,新的地图API是不是很灵活呢。希望谷歌继续改善它。

Unfortunately, the new Maps API is not very flexible yet. Hopefully Google continues to improve upon it.

这篇关于在谷歌地图V2动画标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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