Nitisha Sharma
Nitisha Sharma

Reputation: 259

Google Maps Marker Clustering

I've added updated Google-Maps-iOS-Utils library manually in my project for marker clustering. In cluster manager array, a cluster item is an object of the Spot class having property marker. No error is showing, but custom marker and cluster both are showing. On tapping on cluster item it displays default map marker as well.

My code is on GitHub. Any ideas for how I can solve this?

Upvotes: 0

Views: 2745

Answers (1)

Tarvo Mäesepp
Tarvo Mäesepp

Reputation: 4533

You can replace your marker icon inside cluster like this:

Add GMUClusterRendererDelegate and it's function:

func renderer(_ renderer: GMUClusterRenderer, willRenderMarker marker: GMSMarker) {
        if marker.userData is Spot{
            marker.icon = UIImage(named: "YourMarkerImageName")
        }
    }

If you want to change the cluster icon:

func renderer(_ renderer: GMUClusterRenderer, willRenderMarker marker: GMSMarker) {
            if marker.userData is Spot{
                marker.icon = UIImage(named: "YourMarkerImageName")
            }else{
                marker.icon = UIImage(named: "YourClusterImageName")
            }
        }

Upvotes: 2

Related Questions