我正在使用此 libray在Android中集群GoogleMap.我的问题是如何更新我昨天从Google审阅过的单个项目,没有答案可以解释更新单个项目.我在项目中使用了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集群
发布评论