ClusterManager不重绘标记 [英] ClusterManager isn't redrawing Markers
问题描述
我试图用 ClusterManager
,以我的集群 CustomMapMarker
S,但是当标记数据变化我称之为 mClusterManager.cluster()
的旗杆位置不会改变。
I'm trying to use ClusterManager
in order to cluster my CustomMapMarker
s, but when the marker data changes and I call mClusterManager.cluster()
, the pin positions don't change.
code:
地图更新方法
void updateMap() {
mClusterManager.clearItems();
mClusterManager.addItem(data.getMarker(id));
mClusterManager.cluster();
}
标记更新方法
CustomMarker processMarkerUpdate(JSONObject json) {
CustomMarker cm = new CustomMarker(json.optDouble("latitude", 0.0), json.optDouble("longitude",0.0));
if (json.has("id")) {
cm.setUid(json.getString("id"));
} else {
//If this happens, we stop processing.
throw new InvalidCMException();
}
cm.setLabel(json.optString("label", ""));
return cm;
}
我三重检查坐标和它们在对象变了,但标记没有在地图上移动。
I've triple checked the coordinates and they are changed in the object, but the marker does not move on the map.
我缺少的一个步骤?
推荐答案
我已经重写我的标记
实现的散code()
方法,它显然是造成散型集合平时替换的功能行事靠不住的。我的解决办法是删除我的自定义实现和解决需要它。
I had overridden my Marker
implementation's hashCode()
method, which was apparently causing the usual replacing functionality of hash-type collections to act wonky. My solution was to remove my custom implementation and work around the need for it.
这篇关于ClusterManager不重绘标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!