i have issues calling cluster manager's cluster() method, drawing clusters when oncamerachanged event triggered.
i using same method reloading clusters when create cluster , go map fragment, cluster there time. whenever try reload clusters oncamerachange event, can see have markers, nothing getting drawn.
this method use reloading clusters :
private void reloadclusters(arraylist<checkin> checkins) { if (checkins != null && checkins.size() > 0) { (checkin item : checkins) { mclustermanager.additem(item); } mclustermanager.cluster(); } }
since need cluster items , trigger oncamerachange well, following:
getmmap().setoncamerachangelistener(mclustermanager);
also, within map fragment, have inner class extends defaultclusterrenderer implements oncamerachange listener :
private class checkinrenderer extends defaultclusterrenderer<checkin> implements googlemap.oncamerachangelistener { public void oncamerachange(cameraposition cameraposition) { radius = getradius(); int zoom_level = math.round(getmmap().getcameraposition().zoom); latlng latlng = getmmap().getcameraposition().target; final double lat = latlng.latitude; final double lng = latlng.longitude; if (zoom_level > 6.5) {
whenever zoom level smaller 6.5, query server information helps me create marker, if return not null, use reload method mentioned above result, hoping see clusters drawn.
Comments
Post a Comment