I am using Map Utils library for clustering on map. now, i want change default markers which are showing in map like below:
you can see markers in green circle. i want to change that. i already implemented this. but dont know how to change this. if you anyone know then help to solve this.
Code:
@Override
protected void startDemo() {
getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 10));
mClusterManager = new ClusterManager<MyItem>(this, getMap());
getMap().setOnCameraChangeListener(mClusterManager);
try {
readItems();
} catch (JSONException e) {
Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show();
}
}
private void readItems() throws JSONException {
InputStream inputStream = getResources().openRawResource(R.raw.radar_search);
List<MyItem> items = new MyItemReader().read(inputStream);
mClusterManager.addItems(items);
}
You should implement onBeforeClusterItemRendered
and make your changes by making a custom Renderer class :
public class MarkerClusterRenderer extends DefaultClusterRenderer<MyItem> {
public MarkerClusterRenderer(Context context, GoogleMap map,
ClusterManager<MyItem> clusterManager) {
super(context, map, clusterManager);
}
@Override
protected void onBeforeClusterItemRendered(MyItem item, MarkerOptions markerOptions) {
// use this to make your change to the marker option
// for the marker before it gets render on the map
markerOptions.icon(BitmapDescriptorFactory.
fromResource(R.drawable.your_custom_marker));
}
}
and Don't forget to add your custom Renderer to your Cluster Manager
mClusterManager.setRenderer(new MarkerClusterRenderer(this, mMap, mClusterManager));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With