I was having some troubles when trying to customize the clsutered markers on Google Map. I am using Google Map Android API Library and reference from GoogleMap Documentation. Here are my codes:
private void setUpClusterer() {
googleBasemap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(
1.379348, 103.849876), 11.0f));
mClusterManager = new ClusterManager<EventClusterItem>(this,
googleBasemap);
googleBasemap.setOnCameraChangeListener(mClusterManager);
googleBasemap.setOnMarkerClickListener(mClusterManager);
addItems();
}
private void addItems() {
for (int i = 0; i < convertedGeomList.size(); i++) {
EventClusterItem offsetItem = new EventClusterItem(convertedGeomList.get(i)
.getY(), convertedGeomList.get(i).getX());
mClusterManager.addItem(offsetItem);
}
}
And my EventClusterItem class:
public class EventClusterItem implements ClusterItem {
private final LatLng mPosition;
public EventClusterItem(double lat, double lng) {
mPosition = new LatLng(lat, lng);
}
public LatLng getPosition() {
return mPosition;
}
}
So basically with these codes, it only shows up a red color marker onto the map. I wonder how can I customize the marker with my own image. I know you can do this to customize the marker on the map:
Marker melbourne = mMap.addMarker(new MarkerOptions()
.position(MELBOURNE)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
But I not sure how to implement it in this case. Any guides?
Thanks in advance.
Use answers from these posts:
How to set my own icon for markers in clusterer in Google Maps
How to add title, snippet and icon to ClusterItem?
There is no any guide about this API. You should find the code for this library and try to understand it - it is easy, the code is perfect (but a little bit slow in fact).
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