android - How to determine what cluster item is clicked? -
i using android maps utils. reading list of coordinates online , plotting them cluster items saving them in hash map associates "room" class have created cluster item:
private hashmap roomhashmap = new hashmap();
on clicking info window of cluster item need retrieve room associated cluster item. had implemented using marker no problem in oninfowindowclicklistener added roomhashmap.get(marker) cannot because in info window still requires marker have hashmap of clusteritem
mmap.setoninfowindowclicklistener(new googlemap.oninfowindowclicklistener() { @override public void oninfowindowclick(marker marker) { //ideally want //room currenroom=roomhashmap.get(clusteritem); //but clusteritem not marker } });
googlemap = mfragment.getmap(); googlemap.setmaptype(googlemap.map_type_terrain); googlemap.getuisettings().setzoomcontrolsenabled(true); // true googlemap.getuisettings().setzoomgesturesenabled(true); googlemap.getuisettings().setcompassenabled(true); googlemap.getuisettings().setmylocationbuttonenabled(true); googlemap.getuisettings().setrotategesturesenabled(true); if (googlemap == null) { toast.maketext(getactivity(), "sorry! unable 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 ));
public class myclusterrenderer extends defaultclusterrenderer {
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(item.gettitle()); markeroptions.snippet(item.getaddress()); } @override protected void onclusteritemrendered(myitem clusteritem, marker marker) { super.onclusteritemrendered(clusteritem, marker); //here have access marker }
}
Comments
Post a Comment