Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKMapView clustering if too many Map Pins nearby

I'm wondering if any of you knows a method (library, category, etc.) to cluster iOS MapAnnotations if there are many of them at the same location (e.g. 4 pieces in about 10m).

It doesn't matter to zoom in because they are still overlapping. I've already tried https://github.com/applidium/ADClusterMapView (and sombe other libs) but all of them are made for showing clusters in zoom-out-scenarios. None of them really respect the distance between annotations when zoomed in.

I'm working on an app with an offline-db so a server-side solution is not an option.

thank you for your help!

like image 933
kimar Avatar asked Mar 30 '13 16:03

kimar


2 Answers

You don't need 3rd party framework's anymore. iOS 11 has native clustering support.

You need to implement mapView:clusterAnnotationForMemberAnnotations: method.

Get more details in the Apple example: https://developer.apple.com/sample-code/wwdc/2017/MapKit-Sample.zip

like image 119
ricardopereira Avatar answered Nov 15 '22 08:11

ricardopereira


You should have a look into CCHMapClusterController project, looks exactly like something you are looking for.

like image 21
Kris Avatar answered Nov 15 '22 07:11

Kris