出现标记聚类默认聚类
Posted
技术标签:
【中文标题】出现标记聚类默认聚类【英文标题】:Marker clustering default cluster appearing 【发布时间】:2021-10-22 10:16:06 【问题描述】:所以基本上我想对文档中显示的自定义标记进行聚类。只是没有图片https://developers.google.com/maps/documentation/android-sdk/utility/marker-clustering#maps_android_utils_clustering_info_window-java。我很难理解为什么地图缩放时会出现默认标记
我的 CustomMarker 类看起来像这样
public class CustomMarker extends DefaultClusterRenderer<MapMarker>
private final IconGenerator iconGenerator;
private final IconGenerator clusterIconGenerator;
private final ImageView imageView;
private final int markerWidth;
private final int markerHeight;
public CustomMarker(Context context,
GoogleMap map,
ClusterManager<MapMarker> clusterManager)
super(context, map, clusterManager);
int padding = 0;
markerWidth = 200;
markerHeight = 200;
clusterIconGenerator = new IconGenerator(getActivity());
imageView = new ImageView(getActivity());
imageView.setLayoutParams(new ViewGroup.LayoutParams(markerWidth, markerHeight));
imageView.setPadding(padding, padding, padding, padding);
iconGenerator = new IconGenerator(getActivity());
iconGenerator.setContentView(imageView);
@Override
protected void onBeforeClusterItemRendered(@NonNull MapMarker item, @NonNull MarkerOptions markerOptions)
imageView.setImageURI(Uri.parse(item.getPicture()));
Bitmap icon = iconGenerator.makeIcon();
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)).title(item.getTitle());
super.onBeforeClusterItemRendered(item, markerOptions);
@Override
protected void onBeforeClusterRendered(Cluster<MapMarker> cluster, MarkerOptions markerOptions)
markerOptions.visible(false);
Bitmap icon = clusterIconGenerator.makeIcon(String.valueOf(cluster.getSize()));
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
markerOptions.visible(true);
@Override
protected boolean shouldRenderAsCluster(Cluster cluster)
return cluster.getSize() > 2;
在我设置标记的函数中,我设置了以下内容
感谢您的任何帮助!
【问题讨论】:
【参考方案1】:出现默认集群是因为我没有覆盖
protected void onClusterUpdated(@NonNull Cluster<MapMarker> cluster, @NonNull com.google.android.gms.maps.model.Marker marker)
这个方法应该和你的onBeforeClusterRendered
一样
【讨论】:
以上是关于出现标记聚类默认聚类的主要内容,如果未能解决你的问题,请参考以下文章
数据聚类|深度聚类Deep Comprehensive Correlation Mining for Image Clustering(DCCM)论文研读
数据聚类|深度聚类Deep Comprehensive Correlation Mining for Image Clustering(DCCM)论文研读