更新单项 GoolgeMap Cluster

Update single item GoolgeMap Cluster(更新单项 GoolgeMap Cluster)
本文介绍了更新单项 GoolgeMap Cluster的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 this libray 在 Android 中集群 GoogleMap.我的问题是如何更新我昨天通过谷歌浏览的单个项目,但没有解释更新单个项目的答案.我在我的项目中使用 websocket,所以我需要更新从 websocket 接收到的项目数据.下面看看我的实现.

I am using this libray to cluster GoogleMap in Android. My question is how can I update the single item I have gone through google from yesterday and no answers are there that explains updating single item. I am using websocket in my project so I need to update the data of item that were received from websocket. Look my implementation below.

我的概念是做mClusterManager.remove(项目)mClusterManager.add(item) + mClusterManager.cluster() 每当我从 websocket 接收数据.

My concept is doing mClusterManager.remove(item) mClusterManager.add(item) + mClusterManager.cluster() whenever I receive data from websocket.

和 hasmap 在添加到集群时识别循环中的对象,例如:hashmap.put(_id,mClusterItem[i]);

and hasmap to identify the object on loop while adding to cluseter like : hashmap.put(_id,mClusterItem[i]);

现在,每当收到 websocket 数据时,我都会这样做,

Now, Whenever on websocket data is received I do,

    onDataReceive(String _id,String name, double latlng, ....){
    mClusterManager.remove(hashmap.get(_id));

   appClusterItem[0] = new AppClusterItem(.....);
    mClusterManager.add(appClusterItem[0])  // Here how can I add item 
    mClusterManager.cluster();
    }

但是,上面的代码在收到第一个数据时首先工作,然后从第二次开始,它将继续添加标记并且无法删除,这意味着找不到 mClusterManager.remove(hasmap.get(_id)).而 appClusterItem[0] 是因为我不能使用 hashmap.get(_id);在上述情况下,因为它给出了预期的错误变量.无论如何要删除相同的对象并在该位置添加对象??

However the above code works first when first data receives, then from second time it will just keep adding the marker and fails to remove that means mClusterManager.remove(hasmap.get(_id)) is not found. And appClusterItem[0] is because I cannot use hashmap.get(_id); on above case bacause it give error variable expected. Anyway to remove the same object and add object on that place??

推荐答案

我也尝试通过 mClusterManager.remove 从集群中删除标记,但遇到了一些问题.因此,就我而言,当我收到数据更改时,我会这样做:我删除了需要从列表中删除的项目,使用 mClusterManager.clearItems(); 清除集群上的所有标记并将新数据放入集群.

I also tried to remove marker from cluster via mClusterManager.remove and have some problem with it. So in my case, when I received data changes I make this: I remove item that i need to remove from my list, clear all markers on cluster with mClusterManager.clearItems(); and put fresh data to cluster.

这篇关于更新单项 GoolgeMap Cluster的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)