运行期间更改标记图标 [英] Change marker icon during runtime

查看:140
本文介绍了运行期间更改标记图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来改变运行时谷歌地图Android版API V2标记的图标不会删除/重新添加我想改变它的图标标记?我可以申请转换到它(如旋转)?

感谢。


解决方案

目前你不能在运行时更改标记,逾期不申请转动它。

您可以使用,虽然一个解决办法 - 我工作的一类BlinkingMarker在那里我有在运行时调整标记图像的不透明度

唯一的解决办法,现在是创建具有不同的旋转位图,然后添加/定期删除它们。这种解决方案的问题是,添加/移除标记需要很多的存储器分配,以便它导致恒定垃圾收集。一个更好,更流畅的解决办法是建立所有图像的前期和他们都一次添加到地图中。之后,你可以使用 Marker.setVisible(布尔)函数来显示你当前需要的内容了。

注意:你没有这样做的,因为加入了很多大的位图可能会导致您的应用程序的内存大小变得非常大的衡量你的位图

您可以看看我的解决方法在这里:
https://github.com/balazsbalazs/blinking-marker-mapsv2

这是标志其闪烁(更改位图的不透明度),但在相同的线路就可以申请任何种类的转变。<​​/ P>

Is there a way to change Google Maps Android API v2 marker's icon during runtime without removing/re-adding the marker I want to change its icon? Can I apply transformations to it (like rotation)?

Thanks.

解决方案

Currently you can't change the marker at runtime, neither apply rotation to it.

You can use a workaround though - I'm working on a BlinkingMarker class where I have to adjust the opacity of the marker image at runtime.

The only solution right now is to create Bitmaps with different rotation and then add/remove them periodically. The problem with this solution is that adding/removing markers takes a lot of memory allocation so it results in constant garbage collection. A better and smoother workaround is to create all your images up-front and add all of them to the map at once. After that you can use the Marker.setVisible(boolean) function to display the one that you currently need.

Caution: measure your bitmaps before you do this, because adding a lot of big bitmaps can cause your app's memory size to grow very big.

You can look at my workaround here: https://github.com/balazsbalazs/blinking-marker-mapsv2

This is marker which is blinking (changes the opacity of the bitmap) but on the same lines you can apply any kind of transformation.

这篇关于运行期间更改标记图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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