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
18
votes
6 answers

MKMapview place pin at location (long/lat)

I have latitude and long values and I need to be able to drop a pin at this location. Can anybody provide some advice on how to go about this?
3sl
  • 295
  • 2
  • 4
  • 7
18
votes
2 answers

MapKit (MKMapView): zPosition does not work anymore on iOS11

On iOS11 the zPosition stopped working for the annotationView.layer. Every time the map region changes. No luck with original solution: layer.zPosition = X; No luck with bringViewToFront/SendViewToBack methods Xcode 8.3/9 UPDATE (SOLUTION thanks…
Yaro
  • 1,222
  • 11
  • 15
18
votes
5 answers

Force MKMapView viewForAnnotation to update

So I have a MKMapView with all my pins added, and the colour of the pin is dependent on whether a value is set for that pin. When I first load the app, viewForAnnotation is called and the colours are set accordingly. However, when I update the pin's…
ingh.am
  • 25,981
  • 43
  • 130
  • 177
17
votes
2 answers

Deallocation while key value observers still registered (reverse geocoder)

When my view goes away I get the following message: An instance 0x1c11e0 of class MKAnnotationView was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some…
mlewis54
  • 2,372
  • 6
  • 36
  • 58
17
votes
7 answers

set TintColor to MKAnnotationView image

I'm writing an application for iOS 7.0+ and I wanted to use new feature witch is: imageWithRenderingMode. I have a map annotation with this code: -(MKAnnotationView*)annotationView { MKAnnotationView *annotationView = [[MKAnnotationView alloc]…
Jakub
  • 13,712
  • 17
  • 82
  • 139
17
votes
2 answers

How to stop the viewForAnnotation method from overriding the default user location blue beacon in iOS

Right now I am populating a map view with annotations, and also displaying the user's current location. With the viewForAnnotation method, it overrides all annotations with the default red pin, but I want to return the views for the other…
Hudson Buddy
  • 726
  • 2
  • 9
  • 20
16
votes
1 answer

iOS Swift MapKit making an annotation draggable by the user?

How do I make it possible, using MapKit in Swift, for the user to drag an annotation from one position to another within the map? I have set the annotation view to be draggable, when my map view delegate creates the annotation view, like this: func…
matt
  • 515,959
  • 87
  • 875
  • 1,141
15
votes
1 answer

"_OBJC_CLASS_$_MKAnnotationView", referenced from: ERROR

.framework/MapKit, file was built for i386 which is not the architecture being linked (armv6) Undefined symbols: "_OBJC_CLASS_$_MKAnnotationView", referenced from: objc-class-ref-to-MKAnnotationView in MapViewController.o ld:…
Alex Stelea
  • 1,219
  • 2
  • 18
  • 29
14
votes
1 answer

How to Hide MKAnnotationView Callout?

i'm trying to hide an AnnotationView without touching the pin, is the possible? Thanks! for (id currentAnnotation in self.mapView.annotations) { if ([currentAnnotation isKindOfClass:[MyAnnotation class]]) { } }
user345711
  • 181
  • 2
  • 5
14
votes
1 answer

Scaling MKMapView Annotations relative to the zoom level

The Problem I'm trying to create a visual radius circle around a annonation, that remains at a fixed size in real terms. Eg. So If i set the radius to 100m, as you zoom out of the Map view the radius circle gets progressively smaller. I've been able…
Jonathan
  • 1,592
  • 1
  • 14
  • 28
14
votes
1 answer

Stuck on using MKPinAnnotationView() within Swift and MapKit

I have a working loop to setup annotations for the title and subtitle elements for some working data points. What I want to do within that same loop structure is to set the pin color to Purple instead of the default. What I can't figure out is…
Kokanee
  • 975
  • 4
  • 9
  • 20
14
votes
3 answers

MKMapView annotation is not selectable second time

On my iPad app I am using iOS map to display few points using annotation. I want to display custom callout too when an annotation is been selected. I am using UIPopoverController to show callout. However this works only when first time tap on…
Chinthaka
  • 966
  • 1
  • 13
  • 42
13
votes
2 answers

Animate removal of annotations

I have a map and a set of annotations, each with a 'parent' property. Currently when I add annotations I implement the didAddAnnotationViews method to animate those annotations so they appear to come from their parent's coordinate. Is there a way of…
benwad
  • 6,414
  • 10
  • 59
  • 93
13
votes
1 answer

Customise iOS8 Callout bubble (Swift)

I want to customise the iOS8 MapView Callout bubble which get visualised when clicking on a MKAnnotationView. The Default bubble is a bit limiting (having only Title,Subtitle and 2 accessory view) so I'm struggling to find an alternative solution.…
Claus
  • 5,662
  • 10
  • 77
  • 118
12
votes
3 answers

Why is ViewForAnnotation not called?

I know this question has been asked multiple times, however all of the answers seem slightly different than what is going on in my app. My understanding is that the viewForAnnotation function is called once the mapView has its delegate set to the…
M. Black
  • 353
  • 1
  • 4
  • 20
1
2
3
65 66