Marker marker = mMap.addMarker(markerOptions);
marker.setTag(poi.getKey());
marker.hideInfoWindow();
builder.include(marker.getPosition());
This code works properly because I put as manuel. I did everything marker.tag()
. I used hash key for retriving which my pin.
mClusterManager.addItem()
I want to use this method. But also I want to take marker tag. So I don't want to add to map as Marker marker = mMap.addMarker(markerOptions);
How can I solve this problem?
I want to explain More Detail.
public class PoiItem implements ClusterItem{
private final LatLng mPosition;
private String mTitle;
private String mSnippet;
private String tag;
private ResponsePoi pois;
public PoiItem(ResponsePoi poi,double lat, double lng,String tag) {
mPosition = new LatLng(lat, lng);
pois = poi;
mTitle = poi.getName();
mSnippet = poi.getAddress();
this.tag = tag;
}
private void setMyCluster(){
mClusterManager = new ClusterManager<PoiItem> (MainActivity.this,mMap);
mMap.setOnCameraIdleListener(mClusterManager);
mMap.setOnMarkerClickListener(mClusterManager);
}
setMyCluster();
for(HashMap.Entry<String, ResponsePoi> poi : pois.entrySet()) {
MarkerOptions markerOptions = new MarkerOptions()
.snippet(poi.getValue().getAddress())
.title(poi.getValue().getName())
.position(new LatLng(poi.getValue().getLocation().getL().get(0),poi.getValue().getLocation().getL().get(1)))
.icon(BitmapDescriptorFactory.fromBitmap(smallMarker));
/*
Marker marker = mMap.addMarker(markerOptions);
marker.setTag(poi.getKey());
marker.hideInfoWindow();
builder.include(marker.getPosition()); */
mClusterManager.addItem(new PoiItem(poi.getValue(),poi.getValue().getLocation().getL().get(0),poi.getValue().getLocation().getL().get(1),poi.getKey()));
}