Jack
Jack

Reputation: 11

MapKit performance with large number of annotations

I have to place a large number of annotation on a map (around 3000) with clustering.

I have two approaches, first one is solved with a mix of iOS and backed. The idea is that app passes visibleMapRect to the server on every regionDidChangeAnimated, and the server responds with all annotations that are in the visible area. But the problem is since I'm using iOS 11 MapKit clustering every time annotations are loaded to the map (on every regionDidChangeAnimated) clustering is called and all annotations flash for a second which results in really bad user experience.

The second idea is to load all 3000 annotations on the map in viewDidLoad, register annotations and use mapView.dequeueReusableAnnotationView. I used tableview with 3000 rows with the same method and it performs very well since iOS is recycling views. But I'm not sure for the map on older devices.

So my question is if there's a better approach than these 2, and if no which one is better?

Upvotes: 1

Views: 884

Answers (1)

Farid
Farid

Reputation: 44

The first approach, you just need to calculate distance between b/w old location and new location (on every regionDidChangeAnimated).Define distance cover for server call (5 - 10 meters).

Upvotes: 0

Related Questions