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
12
votes
3 answers

MKMapView ignores update of centerOffset in iOS 4

I previously created a custom callout bubble as a subview to the MKAnnotationView because the built in callout is so limited. This requires me to change to centerOffset of the MKAnnotationView when it is selected to account for the size of the…
HowsItStack
  • 141
  • 1
  • 7
12
votes
6 answers

didSelectAnnotationView not called

I would like to work with an annotation once it's clicked. I've looked it up on the documentation of Apple and I did googled but I can not find why this is any different than how it should be done. Basically; I don't get a println("Pin…
Kraishan
  • 443
  • 5
  • 14
  • 38
12
votes
7 answers

iOS refresh annotations on mapview

I have a mapview where the annotation's coordinates are constantly being updated but when I use setCoordinate, the annotation does not move. How do I refresh the annotations to reflect their coordinates? - (void)updateUnits { PFQuery *query =…
Jon Erickson
  • 1,876
  • 4
  • 30
  • 73
11
votes
1 answer

MKAnnotationView setImage() on iOS 11 has an animation

Since iOS 11, when I use setImage in my custom MKAnnotationView, the image is displayed with an animation. The problem is when I select and deselect the MKAnnotationView and the image has a different size. It results in a weird animation. No problem…
Fonzie f
  • 117
  • 4
11
votes
1 answer

MKMapView moving Annotations Automatically - animate them?

I have a data set of annotations that can update very quickly. At the moment I remove all annotations before replotting them back onto the map. NSArray *existingpoints = [mapView.annotations filteredArrayUsingPredicate:[NSPredicate…
Lee Armstrong
  • 11,420
  • 15
  • 74
  • 122
11
votes
2 answers

MKAnnotationView drawRect: not getting called

I've implemented a custom annotation derived from MKAnnotation called ContainerAnnotation and a custom annotation view derived from MKAnnotationView with a drawRect: method called ContainerAnnotationView. For some reason the drawRect: method is not…
David Potter
  • 2,272
  • 2
  • 22
  • 35
11
votes
3 answers

What initializers should a MKAnnotationView subclass have in Swift?

I'm creating a subclass of MKAnnotationView in my project. It needs to have two properties for storing subviews which I need to initialize somewhere at the beginning. MKAnnotationView has one initializer listed in its documentation,…
Kuba Suder
  • 7,587
  • 9
  • 36
  • 39
10
votes
3 answers

Custom image for MKAnnotation

I have created an annotation which I'm adding to an MKMapView. How would I go about having a custom image instead of the standard red pin? @interface AddressAnnotation : NSObject { CLLocationCoordinate2D coordinate; NSString…
3sl
  • 295
  • 2
  • 4
  • 7
10
votes
1 answer

Why is my map view callout translucent/transparent and how do I change it's color?

I'm on iOS 7 and I have the following problem. I can't find a clue after some research curiously... I have a map view annotation with left and right accessories but transparent in the middle (default iOS 7 behavior I think). How to change the…
Lostania
  • 145
  • 8
10
votes
3 answers

Crash with unrecognized selector when user touches annotation

I have an app for displaying map and custom annotation. My application crashes when the user touches on the annotation. It happens in iOS 7 only. It's working fine with iOS 6 and iOS 5. Following is the crash report which is displayed in the…
Maddy
  • 311
  • 2
  • 11
9
votes
3 answers

iOS MapKit Changing mapview maptype causes annotation image to change to pin?

Any suggestions on what is wrong with the following would be appreciated. I am adding a custom image to an annotation using the following code. - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id…
jimsis
  • 301
  • 4
  • 15
9
votes
1 answer

How to do animation in custom annotation pin when update annotation view

I want to do animation like "when scroll collection view cell the annotation pin goes Up/Down at the end of scrolling. But how to do animation like annotation pin goes Up when start scrolling and annotation pin goes Down when scrolling end in…
Alpesh Desai
  • 313
  • 2
  • 11
9
votes
6 answers

MKAnnotationView and tap detection

I have a MKMapView. I added a UITapGestureRecognizer with a single tap. I now want to add a MKAnnotationView to the map. I can tap the annotation and mapView:mapView didSelectAnnotationView:view fires (which is where I'll add additional logic to…
Padin215
  • 7,444
  • 13
  • 65
  • 103
9
votes
1 answer

Positioning a custom MKAnnotationView

I create a custom MKAnnoationView as follows: - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id )annotation { static NSString* AnnotationIdentifier = @"AnnotationIdentifier"; MKAnnotationView*…
Darren
  • 10,091
  • 18
  • 65
  • 108
9
votes
1 answer

How to set the rotation center of an MKAnnotationView

I've got a problem with my MKAnnotationViews when MKUserTrackingModeFollowWithHeading is enabled on the MKMapView. I positioned my images using the centerOffset property of the MKAnnotationView. Specifying the coordinates of the pin's tip relative…
Chris
  • 3,192
  • 4
  • 30
  • 43
1 2
3
65 66