I have found that there's mostly just Java code examples on Google's development site, and very few in Kotlin too which is pretty annoying so I have to ask this here.
I'm trying to setup a ClusterManager, but i don't have any clues how it's supposed to be done, and there's no Kotlin examples to be seen. I did manage this much:
override fun onMapReady(googleMap: GoogleMap) {
// return early if the map was not initialised properly
mMap = googleMap ?: return
with(mMap.uiSettings) {
isZoomControlsEnabled = true
isMyLocationButtonEnabled = true
isCompassEnabled = true
isRotateGesturesEnabled = true
isZoomGesturesEnabled = true
}
val clusterManager = ClusterManager<ScootMarker>(this, mMap)
mMap.setOnCameraIdleListener(clusterManager)
mMap.setOnMarkerClickListener(clusterManager)
mMap.setOnInfoWindowClickListener(clusterManager)
mMap.setInfoWindowAdapter(CustomInfoWindowAdapter(this))
mMap.mapType = GoogleMap.MAP_TYPE_HYBRID
setUpMap()
getData()
}
I however don't know how I'm supposed to add markers to that ClusterManager, nor how to bind it to my CustomInfoWindowAdapter.
I already have my own custom item done, which returns the snippet, location and title.
Please try the code below for guidance and demonstration of how to add a marker clusterer in Kotlin.
Note that this is based on the Java code implementation from Google's guides [1] [2] and it works without problem for me, so I hope this helps you!
[1] https://developers.google.com/maps/documentation/android-sdk/utility/marker-clustering
[2] https://developers.google.com/maps/documentation/android-sdk/infowindows