如何在不清除和闪烁地图的情况下刷新Google地图上的标记位置? [英] How to refresh markers position on google maps without clearing and blinking the map?

查看:95
本文介绍了如何在不清除和闪烁地图的情况下刷新Google地图上的标记位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建无需更新/闪烁整个地图即可更新的Google Maps V2标记? 目前,我必须清除地图,然后添加标记:

Is it possible to create Google Maps V2 markers which can be updated without blinking/clearing the whole map? Currently i have to clear the map and then add markers:

googleMap.clear();
googleMap.addMarker(new MarkerOptions().position(entry.getValue()).title(entry.getKey()));

但是清除后地图会闪烁...

But then the map blinks when cleared...

推荐答案

addMarker返回Marker对象.

Marker marker = googleMap.addMarker(new MarkerOptions().position(entry.getValue()).title(entry.getKey()));

使用此对象更改其位置:

Use this object to change its position:

marker.setPosition(new LatLng(5, 5));

这篇关于如何在不清除和闪烁地图的情况下刷新Google地图上的标记位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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