我想用我的可绘制图标更改defult群集组图标.
请检查我的集群程序代码.
MyClusterRenderer.java
public class MyClusterRenderer extends DefaultClusterRenderer<MyItem> {
public MyClusterRenderer(Context context, GoogleMap map,
ClusterManager<MyItem> clusterManager) {
super(context, map, clusterManager);
}
@Override
protected void onBeforeClusterItemRendered(MyItem item, MarkerOptions markerOptions) {
super.onBeforeClusterItemRendered(item, markerOptions);
markerOptions.title("").icon(BitmapDescriptorFactory.fromresource(R.mipmap.location_both));// for marker
}
@Override
protected void onClusterItemRendered(final MyItem clusterItem, Marker marker) {
super.onClusterItemRendered(clusterItem, marker);
}
}
安装片段中的代码
googleMap.clear();
mClusterManager = new ClusterManager<MyItem>(getActivity(), googleMap);
googleMap.setonMarkerClickListener(mClusterManager);
googleMap.setonCamerachangelistener(mClusterManager);
readItems();
mClusterManager.setRenderer(new MyClusterRenderer(getActivity(), googleMap, mClusterManager));
解决方法:
尝试在onBeforeClusterRendered方法而不是onBeforeClusterItemRendered方法中更改Cluster图标:
@Override
protected void onBeforeClusterRendered(Cluster<MyItem> cluster, MarkerOptions markerOptions) {
markerOptions.icon(BitmapDescriptorFactory.fromresource(R.mipmap.location_both));
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。