kimar
kimar

Reputation: 211

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!

Upvotes: 6

Views: 6131

Answers (3)

ricardopereira
ricardopereira

Reputation: 11683

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

Upvotes: 4

Kris
Kris

Reputation: 5792

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

Upvotes: 2

incanus
incanus

Reputation: 5128

One alternative is the MapBox iOS SDK, which is an open source (BSD) library replicating MapKit behavior. It does both annotation clustering and offline map layers.

http://mapbox.com/mobile

Upvotes: 0

Related Questions