我正在使用Android Maps Utils。我正在从在线阅读坐标列表并将它们绘制为集群项目,并将它们保存在一个哈希映射中,该映射将一个" Room"我为集群项创建的类:
private HashMap roomHashMap = new HashMap();
单击此群集项的信息窗口时,我需要检索与群集项关联的房间。我使用了一个没有问题的标记实现了这个,因为onInfoWindowClickListener我刚刚添加了roomHashMap.get(标记),但现在我不能这样做,因为在信息窗口中它仍然需要一个标记,但我有一个ClusterItem的HashMap
mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
//Ideally I want this
//Room currenRoom=roomHashMap.get(clusterItem);
//but clusterItem is obviously not a Marker
}
});
答案 0 :(得分:0)
i
公共类MyClusterRenderer扩展了DefaultClusterRenderer {
googleMap = mFragment.getMap();
googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
googleMap.getUiSettings().setZoomControlsEnabled(true); // true to
googleMap.getUiSettings().setZoomGesturesEnabled(true);
googleMap.getUiSettings().setCompassEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.getUiSettings().setRotateGesturesEnabled(true);
if (googleMap == null) {
Toast.makeText(getActivity(), "Sorry! unable to create maps",
Toast.LENGTH_SHORT).show();
}
mClusterManager = new ClusterManager<MyItem>(getActivity(), googleMap );
googleMap.setOnMapLoadedCallback(this);
googleMap.setMyLocationEnabled(true);
googleMap.setBuildingsEnabled(true);
googleMap.getUiSettings().setTiltGesturesEnabled(true);
markers = new Hashtable<String, String>();
mClusterManager.setRenderer(new MyClusterRenderer(getActivity() , googleMap , mClusterManager ));
}