Good afternoon!
I have integrated Google Maps into my Android application and I have clustered points on the map. For this I created a separate class:
public class MyClusterItem implements ClusterItem {
private final LatLng position;
public final Integer vectorId;
public List<String> types;
public MyClusterItem(double lat, double lng, List<String> types, int vectorId) {
position = new LatLng(lat, lng);
this.types = types;
this.vectorId = vectorId;
}
// some overrides
public List<String> getTagCluster(){ return types;}
}
When creating a cluster object, I pass an array into it as a tag:
MyClusterItem newItem = new MyClusterItem(pointLoc.latitude, pointLoc.longitude, pointObj.types, vectorId);
clusterManager.addItem(newItem);
Also I have InfoWindowAdapter. I installed it like this:
map.setInfoWindowAdapter(new CustomInfoWindowAdapter(getContext(), map));
map.setOnInfoWindowClickListener(marker -> {
// i need to get TAG here
});
Only the object with the tag is passed to the InfoWindowAdapter, not MyClusterItem. How to get this tag inside InfoWindowClickListener?
P.S.
My CustomClusterItemRenderer looks like this:
private class CustomClusterItemRenderer extends DefaultClusterRenderer<MyClusterItem> {
public CustomClusterItemRenderer(Context context, GoogleMap map, ClusterManager<MyClusterItem> clusterManager) {
super(context, map, clusterManager);
}
@Override
protected void onBeforeClusterItemRendered(@NonNull MyClusterItem clusterItem, MarkerOptions markerOptions) {
markerOptions.icon(bitmapDescriptorFromVector(getContext(), clusterItem.vectorId))
.title(clusterItem.getTitle());
}
private BitmapDescriptor bitmapDescriptorFromVector(Context context, int vectorResId) {
//a lot of code
return BitmapDescriptorFactory.fromBitmap(bitmap);
}
}
That is, if I could insert a tag using MarkerOptions, then it would work. But this is impossible. (i think so)