Igor
Igor

Reputation: 461

How to display two annotations with the same coordinates on the map?

I have two annotations with the same coordinates. And I have to display them on the map. When I add these annotations on the map I see just one pin. How can I display two annotations instead of one? Or how can I display a annotations list by clicking on the pin? Can anybody help me? Thanks in advance. Igor

Upvotes: 3

Views: 1147

Answers (1)

Tim
Tim

Reputation: 60140

When you try to display multiple annotations at the same coordinate on a map using MapKit, generally it will actually place two different pins, but they will be in the exact same location. You can compare the difference in the shadow strength to see the difference, however; look at a single pin's shadow, then look at your double-pin shadow, and you should see the latter appear darker.

In terms of indicating to your user that there are multiple pins, there are several ways you could do that. You might consider implementing the title or subtitle properties on your annotations to display the number of annotations at the same coordinates (e.g. set subtitle to the string @"(and two more)" or similar). Then, when the callout accessory view is tapped, push (onto a navigation controller stack) a table view of annotations at that location.

Upvotes: 1

Related Questions