0

I implemented it by following https://developers.google.com/maps/documentation/ios-sdk/utility/marker-clustering.

However, there is one problem.

I did not know how to control the color and transparency of the cluster marker.

I looked through the search, but I could not understand any other language code, including Object-C.

let iconGenerator = GMUDefaultClusterIconGenerator ()
let algorithm = GMUNonHierarchicalDistanceBasedAlgorithm ()
let renderer = GMUDefaultClusterRenderer (mapView: mapView, clusterIconGenerator: iconGenerator)

I also found that this can be solved.

I want to get a way to control the border, background color, transparency, and size of the cluster marker (Circle).

Please help me.

2 Answers 2

1

If you only need to change the color you can add buckets with multiple colors when initializing your GMUDefaultClusterIconGenerator (or just one as in the case below if you only need one color). I used a large number (higher than the max number of cluster items) so that all clusters will have the same color. To use multiple colors you can add multiple buckets and multiple colors.

let iconGenerator = GMUDefaultClusterIconGenerator.init(buckets: [99999], backgroundColors: [UIColor.red])
let algorithm = GMUNonHierarchicalDistanceBasedAlgorithm()
let renderer = GMUDefaultClusterRenderer(mapView: googleMapView, clusterIconGenerator: iconGenerator)

clusterManager = GMUClusterManager(map: googleMapView, algorithm: algorithm, renderer: renderer)
clusterManager.setDelegate(self, mapDelegate: self)

To use an image as your cluster background you can create a custom GMUClusterRenderer as you indicated or you can provide a group of backgroundImages for your buckets:

let iconGenerator = GMUDefaultClusterIconGenerator.init(buckets: [99999], backgroundImages: [UIImage(named: "YOUR_IMAGE_HERE")!])
Sign up to request clarification or add additional context in comments.

Comments

0

I found an answer with a perfect solution.

@Andr3a88 Answer : How to implement GMUClusterRenderer in Swift

The correct answer was to create the image rather than draw a circle in the script.

In the above script could also change the text.

The number of questions proves that many people like me are experiencing errors.

So I will leave a few questions to help you find a more complete solution.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.