在我的应用程序中,我在谷歌地图上放置了超过50K的标记。我想自定义标记群集渲染器。标记上显示的数字不正确,显示错误的数字,它不包含它在标记上显示的数字引脚。请帮我解决这个问题。我使用以下代码来聚类标记:
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 10));
// Initialize the manager with the context and the map.
// (Activity extends context, so we can pass 'this' in the constructor.)
mClusterManager = new ClusterManager<MyItem>(this, mMap);
mClusterManager.setRenderer(new MyClusterRenderer<MyItem>(this, mMap,mClusterManager));
// Point the map's listeners at the listeners implemented by the cluster
// manager.
mMap.setOnCameraChangeListener(mClusterManager);
mMap.setOnMarkerClickListener(mClusterManager);
addItems();
添加项目的功能
private void addItems() {
for (int i = 0; i < placesCoordinates.size(); i++) {
MyItem offsetItem = new MyItem(placesCoordinates.get(i).getLat(), placesCoordinates.get(i).getLng());
mClusterManager.addItem(offsetItem);
}
}
坐标数据集:
placesCoordinates.add(new Places(40.763557,-73.972302,true));
placesCoordinates.add(new Places(40.762123,-73.974824,true));
placesCoordinates.add(new Places(40.722165,-73.999198,true));
placesCoordinates.add(new Places(40.758037,-73.97699 ,true));
placesCoordinates.add(new Places(40.750718,-73.988592,true));
placesCoordinates.add(new Places(40.763502,-73.97395 ,true));
placesCoordinates.add(new Places(40.757155,-73.978499,true));
placesCoordinates.add(new Places(40.720076,-73.997571,true));
placesCoordinates.add(new Places(40.721643,-74.000222,false));
placesCoordinates.add(new Places(40.752877,-73.99622 ,true));
placesCoordinates.add(new Places(40.743386,-73.993546,true));
placesCoordinates.add(new Places(40.7403, -73.995,true));
placesCoordinates.add(new Places(40.706925,-74.004398,true));
placesCoordinates.add(new Places(40.7225, -73.988314,true));
placesCoordinates.add(new Places(40.721334,-73.988946,true));
placesCoordinates.add(new Places(40.760245,-73.984354,true));
placesCoordinates.add(new Places(40.711741,-74.008775,true));
placesCoordinates.add(new Places(40.734311,-73.990107,true));
placesCoordinates.add(new Places(40.760964,-73.968482,true));
placesCoordinates.add(new Places(40.762424,-73.973481,true));
placesCoordinates.add(new Places(40.762424,-73.973481,true));
placesCoordinates.add(new Places(40.73487,-73.991409 ,true));
placesCoordinates.add(new Places(40.761488,-73.967123,true));
placesCoordinates.add(new Places(40.795354,-73.931178,true));
placesCoordinates.add(new Places(40.784815,-73.979711,true));
placesCoordinates.add(new Places(40.739037,-73.995811,true));
placesCoordinates.add(new Places(40.734279,-73.990288,false));
placesCoordinates.add(new Places(40.724569,-73.996485,false));
placesCoordinates.add(new Places(40.741841,-73.992895,false));
placesCoordinates.add(new Places(40.739293,-73.994109,false));
placesCoordinates.add(new Places(40.725744,-73.996881,false));
placesCoordinates.add(new Places(40.712914,-74.007793,false));
placesCoordinates.add(new Places(40.760388,-73.98506 ,false));
placesCoordinates.add(new Places(40.72562,-73.999731 ,false));
placesCoordinates.add(new Places(40.735868,-74.004994,false));
placesCoordinates.add(new Places(40.742092,-73.991766,false));
placesCoordinates.add(new Places(40.758243,-73.984917,false));
placesCoordinates.add(new Places(40.738153,-73.989673,false));
placesCoordinates.add(new Places(40.722836,-73.999158,false));
placesCoordinates.add(new Places(40.741049,-73.991926,false));
placesCoordinates.add(new Places(40.762424,-73.973481,false));
placesCoordinates.add(new Places(40.73487,-73.991409 ,false));
placesCoordinates.add(new Places(40.761488,-73.967123,false));
placesCoordinates.add(new Places(40.795354,-73.931178,false));
placesCoordinates.add(new Places(40.784815,-73.979711,false));
placesCoordinates.add(new Places(40.739037,-73.995811,false));
placesCoordinates.add(new Places(40.734279,-73.990288,false));
placesCoordinates.add(new Places(40.724569,-73.996485,false));
placesCoordinates.add(new Places(40.741841,-73.992895,true));
placesCoordinates.add(new Places(40.739293,-73.994109,true));
placesCoordinates.add(new Places(40.725744,-73.996881,true));
placesCoordinates.add(new Places(40.712914,-74.007793,true));
placesCoordinates.add(new Places(40.760388,-73.98506 ,true));
placesCoordinates.add(new Places(40.72562,-73.999731 ,true));
placesCoordinates.add(new Places(40.735868,-74.004994,true));
placesCoordinates.add(new Places(40.742092,-73.991766,true));
placesCoordinates.add(new Places(40.758243,-73.984917,true));
placesCoordinates.add(new Places(40.738153,-73.989673,true));
placesCoordinates.add(new Places(40.722836,-73.999158,true));
placesCoordinates.add(new Places(40.741049,-73.991926,true));
答案 0 :(得分:0)
在完成调试一整天之后,我发现问题不在于群集标记编号,实际上问题在于我的数据集。它包含多次类似的坐标。