efremidze / Cluster

Easy Map Annotation Clustering 📍
MIT License
1.28k stars 121 forks source link

AnnotationViews are overlapping #97

Open schnfld opened 6 years ago

schnfld commented 6 years ago

New Issue Checklist

Issue Description

I tried almost everything and don't know, why I am not getting this thing to work. So I added a custom annotation view, subclass of ClusterAnnotationView. Its size is 50x50. I added the Delegate method:

func cellSize(for zoomLevel: Double) -> Double { return 80 }

And this is my configuration:

clusteringManager.delegate = self clusteringManager.shouldDistributeAnnotationsOnSameCoordinate = true clusteringManager.minCountForClustering = 2 clusteringManager.shouldRemoveInvisibleAnnotations = true clusteringManager.clusterPosition = .average clusteringManager.maxZoomLevel = 15

But I still ending up with this overlapping:

img_0045

Environment

efremidze commented 6 years ago

The clusterPosition is causing the overlap. If you set clusterPosition to .center, it should fix your issue.

manager.clusterPosition = .nearCenter simulator screen shot - iphone 7 - 2018-10-19 at 12 44 08

manager.clusterPosition = .center simulator screen shot - iphone 7 - 2018-10-19 at 12 46 58

schnfld commented 6 years ago

Thanks for the quick reply! This seemed to fix the overlapping but now the cluster is moving continuously to other positions when zooming, which could confuse the user. Also, it's clustering the annotations in one cluster, then creates two out of it and goes back to one cluster.

ezgif-3-191bbe867505

By the way: How can I display the grid on the map for debugging purpose?

efremidze commented 6 years ago

I would give some extra space for the cellSize to avoid it jumping when zooming. I'll add a debug view to see cellSize boundaries.

schnfld commented 6 years ago

I tried it with 80, 100, 150 for the 50x50 view. It seems that when the cell gets bigger also the jumping gets more affected. Here an example with 150, its contounysly moving arround:

ezgif-3-9ab4119c1df2

efremidze commented 6 years ago

You are right. I'll look into why it jumps.