Reputation: 474
I am working on the map application and as per requirement i need to show a single pin for a single region even if it has multiple user coordinates when its completely zoomed out but when its zoomed in to the map then i should display all the pins as per its coordinates. I have given example below to explain my problem. I have city New York on this city I have 100 pins on my mapview when I am zooming out of my map it should show me only one annotation pin on the place of 100 pins but when I am zooming in then it should show again 100 pin on map. Does any one knows about this. I need suggestion. Please note that I am getting all the locations from web services except my current location. This should not be affecting application so that application shouldn't become slow.
Please suggest some solution.
Upvotes: 2
Views: 1921
Reputation: 5766
Of course there is a control for that...
Take a look at OpenClusterMapView, it should be exactly what you need.
Upvotes: 4
Reputation: 6710
There is no API for this.
You will need to manage the pins yourself. As a user zooms in on the map, you will need to decide at what point to remove the aggregated pin and add the individual pins. Inversely, as a user zooms out you will need to remove the individual pins and replace with the aggregated pin.
Might be a good idea to use a custom pin for the aggregated pin to suggest that it represents multiple pins.
I think this link might help you know the current zoom level:
Link to a similar question:
Upvotes: 3
Reputation: 458
The Apple WWDC 2011 video, "Visualizing information geographically with MapKit", https://developer.apple.com/videos/wwdc/2011/ shows how to cluster map annotations - it's exactly what you need.
Upvotes: 6