Belzik
Belzik

Reputation: 529

How to cluster points with different images (icons)? MapBox

Friends, I need to cluster points with different pictures (icons). Could you tell me by what means I can do it? How do this with the mapbox iOS SDK.

Task: From the server I receive around 2000 images, each image corresponds to a certain coordinate. When I got their point data with an image, I'm adding a cluster to the map.

I want to see something like this on my map: enter image description here

Upvotes: 1

Views: 1013

Answers (2)

Belzik
Belzik

Reputation: 529

In order to cluster points with different icons - there is a library.

https://github.com/hulab/ClusterKit

This proved to be the solution to my problem.

Upvotes: 0

Jake T.
Jake T.

Reputation: 4378

SymbolStyleLayers can only have one image for all points.

Do you need to be able to tap these to perform an action? That only works with features added to a MGLSymbolStyleLayer, and you'll want to add them as features, not regular PointAnnotations.

If not, I would just subclass MGLPointAnnotationFeature and have an attributes item for the UIImage, and use the delegate method imageForAnnotation to see if the annotation is of your subclass, and, if so, return the UIImage packaged into an MGLAnnotationImage.

Upvotes: 0

Related Questions