Questions tagged [mkannotationview]

MKAnnotationView is part of Apple's Map Kit framework for developing iOS applications, an object that represents annotations visually in a map view.

Annotation views are loosely coupled to a corresponding annotation object, which is an object that corresponds to the MKAnnotation protocol. When an annotation’s coordinate point is in the visible region, asks its delegate to provide a corresponding annotation view. Alternatively (and simpler in many cases), you can simply register an particular annotation view with a particular identifier (notably the MKMapViewDefaultAnnotationViewReuseIdentifier and MKMapViewDefaultClusterAnnotationViewReuseIdentifier identifiers). Annotation views may be recycled later and put into a reuse queue that is maintained by the map view

Annotation views remain anchored to the map at the point specified by their associated annotation object. Although they scroll with the map contents, annotation views reside in a separate display layer and are not scaled when the size of the visible map region changes.

You can use the MKAnnotationView class as-is, use an existing subclass (such as MKMarkerAnnotationView), or subclass it yourself to provide custom behavior as needed. The image property of the class lets you set the appearance of the annotation view without subclassing directly.

See also

986 questions
3
votes
1 answer

Custom annotation view is being removed from its superview after setting map view center coordinate

I'm working on a location-aware application that is using MKMapView with custom callout bubbles implemented as MKAnnotationView subclass. Yesterday I've encountered a subtle bug when custom annotation view is not being shown. After investigating…
3
votes
2 answers

Custom MKAnnotationView - How to capture touches and NOT dismiss the callout?

I have a custom MKAnnotationView subclass. It is showing the view exactly as I want it to. In that view, I have a button. I want to capture events on the button to perform an action. This works just fine. However, I do NOT want the callout to be…
thephatp
  • 1,479
  • 1
  • 20
  • 37
3
votes
1 answer

how to change default image in MKUserLocation annotation in Swift iOS

I have a map view in my app that displays the user's location. when the user's location is tapped an image is displayed as below: is there a way to make this image customized to my liking, so for instance I would like to show the photo that the…
user14279703
3
votes
1 answer

How to custom the image of MKAnnotation pin

I am trying to change the image that is inside the MKAnnotation without removing the rounded shape. Here I create a custom class of MKAnnotation: class MapPin: NSObject, MKAnnotation { let title: String? let locationName: String let…
Edoardo
  • 657
  • 7
  • 24
3
votes
1 answer

Adding multiple annotations with multiple images on mapview in ios Objective-c?

I am working on an old application and need to make changes in Mapview. Previously we need to show multiple annotations on mapview with same images on each pin but now we have to show different images on annotation view pins to display address. I am…
Abhinandan Pratap
  • 2,142
  • 1
  • 18
  • 39
3
votes
1 answer

I have 30 annotations, and growing. Looking for a simpler way to code this?

I am coding multiple annotations into a project. Currently I have 30 annotations, and growing. I'm wondering if there is a simplier way of having to create a annotation.h and annotation.m classes for each single annotation. Currently in my map view…
Anton Smith
  • 1,368
  • 2
  • 10
  • 15
3
votes
1 answer

Make a MKAnnotation placemark always visible

I want the placemark (title and subtitle) of a MKAnnotation object to be visible on the mapview at anytime without clicking on it.
bobby grenier
  • 2,090
  • 2
  • 14
  • 11
3
votes
0 answers

Standart AnnotationView with Multiline in MKMapView

I want to show my description of Annotation with several lines of text (such as phone, description, address), I found the solution here. I must create my own child MKAnnotationView class and override method initWithAnnotation, where I'm able to draw…
Viktor Magaev
  • 125
  • 1
  • 1
  • 11
3
votes
1 answer

MapKit how to opt-out from clustering when an annotation is selected

I’m using iOS 11 clustering and it works really fine, basically you just need to ad an identifier to the clusteringIdentifier property of an MKAnnotationView. Everything works perfectly but I have an issue, when a user select a marker from a map…
Andrea
  • 26,120
  • 10
  • 85
  • 131
3
votes
1 answer

Set glyphText of MKMarkerAnnotationView for MKClusterAnnotation

I have a class MapItem which implements MKAnnotation protocol. I am using MKMarkerAnnotationView for displaying Annotations on map. According to Documentation, glyphText property of MKMarkerAnnotationView when set to nil, it produces pin image on…
FE_Tech
  • 1,534
  • 13
  • 25
3
votes
0 answers

Perform didSelect before didDeselect

The title might not due the actually question justice since there might be a completely different solution to this problem. What we are trying to do is create a snapchat like map view, where data is displayed on the bottom of the screen in a…
NoSixties
  • 2,443
  • 2
  • 28
  • 65
3
votes
1 answer

Change Pin Image of MKMapView on specific zoom In-Out iOS Swift 4

My Current MKMapView is: But when I zoom in I want to change Pin Image to this: and again zoom out change to default violet circle. I just want to change Pin Image when user zoom In/Out MKMapView in iOS Swift 4. Thanks In Advance! Happy Coding!
Sachin Dobariya
  • 744
  • 7
  • 16
3
votes
1 answer

MKAnnotationView scaling image causes calloutView to scale as well

So I have a number of bus stops that are marked as annotations on the map. Instead of the default red bubble or the pin, I wanted to use an image of a bus stop sign, so I successfully changed the image. In doing so, because the image is 512x512, I…
dinosaysrawr
  • 348
  • 2
  • 15
3
votes
1 answer

Custom MKAnnotationView location drastically changes when rotate or zoom in/out of map

I've got two custom MKAnnotationViews, which display fine when they are initially added to the MKMapView. The issue is, when rotating, or zooming out, their drawn locations seem to become more and more off. To reiterate, the closer I zoom in, the…
royherma
  • 4,095
  • 1
  • 31
  • 42
3
votes
1 answer

How to z-order MKAnnotationViews?

I've tried the two methods found in these stackoverflow posts without luck: post a, post b. The methods are, a, to bring the view to front from the superview, b, to set the z postion of the layer of the view. Dose anyone know a third way?
Heestand XYZ
  • 1,993
  • 3
  • 19
  • 40