I\'m developing an app on which I want to show a lot of events on the map. The user can click on an event and see a lot of informations about it. In another view, a user can
Firstly loadMarker() should be called after the clusterManager is initialized i.e
clusterManager = GMUClusterManager(map: maMap, algorithm: algorithm, renderer: renderer)
then
clusterManager.cluster()
clusterManager.setDelegate(self, mapDelegate: self)
should be placed in loadMarker() after for loop ends.
Your viewcontroller should conform to this protocol GMUClusterManagerDelegate then add these 2 methods in viewcontroller.
func renderer(_ renderer: GMUClusterRenderer, markerFor object: Any) -> GMSMarker? {
let marker = GMSMarker()
if let model = object as? MarkerModel {
// set image view for gmsmarker
}
return marker
}
func clusterManager(_ clusterManager: GMUClusterManager, didTap cluster: GMUCluster) -> Bool {
let newCamera = GMSCameraPosition.camera(withTarget: cluster.position, zoom: mapView.camera.zoom + 1)
let update = GMSCameraUpdate.setCamera(newCamera)
mapView.moveCamera(update)
return false
}
Try this and let me know if this works else we will try something else.