1
マップにマーカーとして使用しているDefaultClusterRendererクラスと独自のClusterItemがあります。 MarkerOptionsでタイトルとスニペットを設定しているので、onInfoWindowClickイベントでそれらをグラブできます。新しいアクティビティを開始するには、ユーザーがクリックしたinfoWindowに依存しますが、MarkerOptionsにタグを追加することはできません。したがって、Markerパラメータを使用してonInfoWindowClickメソッドでタグを取得できません。MarkerOptions .tag not available
私は各ClusterItemにidを追加し、onInfoWindowClickのMarkerを介してIDを取得するのがよい解決策を探しています。
public class OwnClusterRendering extends DefaultClusterRenderer<GeoPoint> {
private GoogleMap map;
public OwnClusterRendering(Context context, GoogleMap map, ClusterManager<GeoPoint> clusterManager) {
super(context, map, clusterManager);
this.map = map;
}
protected void onBeforeClusterItemRendered(GeoPoint geoPoint, MarkerOptions markerOptions) {
markerOptions.icon(geoPoint.getIcon());
markerOptions.snippet(geoPoint.getSnippet());
markerOptions.title(geoPoint.getTitle());
super.onBeforeClusterItemRendered(geoPoint, markerOptions);
}
}
MyCustomWindowAdapter:
@Override
public void onInfoWindowClick(Marker marker) {
Log.d("test", marker.getTitle());
Log.d("test", marker.getSnippet());
Log.d("test", marker.getId());
Log.d("test", String.valueOf(marker.getTag()));
// Intent intent = new Intent(context, StoneInfoSliderActivity.class);
// context.startActivity(intent);
}