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
5
votes
1 answer

MapKit Annotations not showing up on map

I'm having trouble getting the MKAnnotationViews show up on the map in MapKit. I'm using iOS 7, and have now searched the forums and the web for many hours, trying different samples and setups. Below I have the most basic setup possible (I think) to…
Canis
  • 4,130
  • 1
  • 23
  • 27
5
votes
0 answers

Update UILabel-Subview of MKAnnotationview

I have a MapView with cluster annotations (ADMapCluster). I want to show the amount of elements in the Cluster, therefor I'm adding a UILabel to the MKAnnotationView as a Subview. My Problem is that when I reuse the MKAnnotationView after zooming…
5
votes
1 answer

Layout relation between MKAnnotationView and its rightCalloutAccessoryView has changed in iOS7

An UIButton is set to the rightCalloutAccessoryView of the MKPinAnnotationView, and it fires btnClicked: method. In iOS6, the layout relation between MKAnnotationView and its rightCalloutAccessoryView can be easily used to find the…
lu yuan
  • 7,207
  • 9
  • 44
  • 78
5
votes
3 answers

My Custom MKAnnotationView isn't clickable

i'm working on a custom annotationview that show a image of background, with inside a custom image. I've based my code from this: Custom MKAnnotationView with frame,icon and image And my actually code is: else if ([annotation…
Riccardo Rossi
  • 161
  • 1
  • 9
5
votes
1 answer

MapKit changes annotation view order when map is scrolled in XCode 4.6

I am an experienced iOS developer, but this has really stumped me. I am simultaneously submitting a problem report to Apple. I'm adding annotations to a MKMapKit map (Xcode 4.6). Each annotation is a MyAnnotation class; MyAnnotation defines a…
zgreycoat
  • 71
  • 2
5
votes
3 answers

MKMapview annotation dynamic pin image changes after zooming

I am working on a little project that shows 7 different types of annotations on the map. My annotations are taken from a url result in array and I parse it using JSON. I have lots of annotations and everything seems to look good once the map loads.…
Roy K
  • 3,319
  • 2
  • 27
  • 43
5
votes
1 answer

Tap an MKAnnotationView to de-select it and hide it's callout

I have an iOS app with custom annotations. I want to be able to tap an MKAnnotationView once to show it's callout (works fine) and then I want to tap the MKAnnotationView a second time to de-select the annotation and hide the callout for that…
Will Haley
  • 703
  • 1
  • 9
  • 25
5
votes
5 answers

MKAnnotation display all pin titles without clicking

I am adding multiple annotations programmatically like this: - (void)addAnnotations{ NSInteger i; CLLocationCoordinate2D location; for ( i = 0 ; i < [storeLatitude count] ; i ++ ){ location.latitude = [[storeLatitude…
Rowie Po
  • 1,339
  • 4
  • 13
  • 17
4
votes
2 answers

iOS MapKit Annotation, not showing correct location

I using a custom image for my mapkit annotation. But the main problem it seems that I am running into in using a custom image, is that when zoomed out, the annotation is not in the correct point on the map, and ONLY until I zoom in all the way down,…
J de la Rama
  • 41
  • 1
  • 2
4
votes
0 answers

Add SwiftUI view to UIView subview, without access to parent UIViewController

I have seen many examples of how to add a SwiftUI view into a UIKit view using Container Views, which assume you have access to the parent UIViewController on the UIKit side. I have a case where I can't do that; specifically, I want to add a SwiftUI…
Z S
  • 7,039
  • 12
  • 53
  • 105
4
votes
1 answer

Dragging annotation view causes multiple triggering of drag state delegate method

This one is a bit obscure. This MKMapViewDelegate has a method which is supposed to tell you when you sart and finish dragging an annotation view. I have implemented like so: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView…
cannyboy
  • 24,180
  • 40
  • 146
  • 252
4
votes
1 answer

Update AnnotationView after/during zoom

I need to change the centerOffset property of an AnnotationView when the zoomlevel changed. I don't want to remove and add the Annotations again. So how can I access and update the AnnotationViews after zooming? Any ideas on this? Best…
cweinberger
  • 3,518
  • 1
  • 16
  • 31
4
votes
3 answers

How to check if annotation is clustered (MKMarkerAnnotationView and Cluster)

I'm trying to work with the new features added to the mapview in ios11. I'm clustering all my MKAnnotationView with circle collision but I have to check in real time when the annotation becomes clustered. I have no idea how to do that. EDIT…
4
votes
0 answers

Why my map view doesn't show my custom clusters?

I'm trying to add custom clusters to my map by using MKClusterAnnotation.To do that, I configure a subclass of MKAnnotationView and inside of it I configure the cluster itself. After that, I register my cluster in map view's view controller by this…
Tigran Iskandaryan
  • 1,371
  • 2
  • 14
  • 41
4
votes
0 answers

Best way to remove some annotations from an MKMapView

To remove some annotations from an MKMapView, but not all of them, based on some condition, there seems to be 3 ways. I'd like to know which is the best one, and if there are any pitfalls with any of them. Thank you. First way: removing annotations…
invalidArgument
  • 2,289
  • 4
  • 24
  • 35