2

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.

Vivek Kalkur
  • 2,200
  • 2
  • 21
  • 40
Dipti Y W
  • 474
  • 1
  • 8
  • 26

3 Answers3

6

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.

paul.lander
  • 458
  • 4
  • 5
  • i gone through the pdf provided by apple but i couldn't got exact solution. Do you know which class or code should i use if i want to place pins as per my zoom level? – Dipti Y W Jan 02 '12 at 11:08
  • I found the PDF a little cryptic. The video though is a step-by-step guide. As bbarnhart says, there is no API (or class) that has MKAnnotation clustering functionality. Apple shows you the design pattern and you can paste code snippets from their Xcode project that's shown in the video. – paul.lander Jan 02 '12 at 16:50
  • The source code doesn't seem to be available for this project – Daniel Oct 08 '12 at 17:10
  • App-Frameworks - Videos - #12 Session 111 https://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/adc.apple.com.8270634034.08270634040.8367260907?i=1094325693 – Bishal Ghimire Jun 17 '13 at 11:48
4

Of course there is a control for that...
Take a look at OpenClusterMapView, it should be exactly what you need.

yinkou
  • 5,756
  • 2
  • 24
  • 40
3

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:

Zoom and Region

Link to a similar question:

Pin Overlap

Community
  • 1
  • 1
bbarnhart
  • 6,620
  • 1
  • 40
  • 60