更新单项 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Show progress during FTP file upload in a java applet(在 Java 小程序中显示 FTP 文件上传期间的进度)
How to copy a file on the FTP server to a directory on the same server in Java?(java - 如何将FTP服务器上的文件复制到Java中同一服务器上的目录?)
FTP zip upload is corrupted sometimes(FTP zip 上传有时会损坏)
Enable logging in Apache Commons Net for FTP protocol(在 Apache Commons Net 中为 FTP 协议启用日志记录)
Checking file existence on FTP server(检查 FTP 服务器上的文件是否存在)
FtpClient storeFile always return False(FtpClient storeFile 总是返回 False)