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

Animated AnnotationView disappears while zooming the mapview?

I add a CABasicAnimation to the AnnotationView layer to simulate a car moving on the mapview. This works fine until I try to zoom in or out the mapview when the animation is in progress. I found the animating annotation view disappears when zooming…
9
votes
4 answers

how to add custom callout view in mapview

I am new to mapkit in objective-c. I am able to add custom annotation in mapview. i need to place custom callout view like below image . But i didn't get how can i design callout view like this. i know i need to add callout in view for…
Mahesh Babu
  • 237
  • 3
  • 10
8
votes
2 answers

Annotation Image is replaced by RedPushPin when long press on annotation

I have created Custom Annotation with following: -(MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation { MKPinAnnotationView *view = nil; if (annotation != mapView.userLocation) { view =…
Krishna
  • 368
  • 5
  • 17
8
votes
1 answer

show users location blue point in iPhone MKMapView

I am developing a custom pins in a MapView in my iPhone app. Here is the code: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation { static NSString *AnnotationViewID = @"annotationViewID"; …
ValentiGoClimb
  • 750
  • 3
  • 13
  • 23
8
votes
2 answers

Adding Multiple Annotations to Map But All Show Some of Same Data

UPDATE 2: Here is the existing code within maps, but it is like the annotations get all out of order with the pins. One time a pin will be green, the next time I run it, the same pin is red. Where is the disconnect coming from? -(void)…
user717452
  • 33
  • 14
  • 73
  • 149
8
votes
1 answer

must implement title when canShowCallout is YES

I'm getting this exception when trying to show the callout on my map annotation, even if the title is set. This is the init method I'm using in my MapAnnotation class: - (id)initWithTitle:(NSString *)ttl subtitle:(NSString *)sub…
Aleph72
  • 877
  • 1
  • 13
  • 40
8
votes
3 answers

Dragging the map after dragging my MKAnnotationView does not move the MKAnnotationView with it

MKPinAnnotationView does not allow you to use a custom image as 'pin' and enable dragging at the same time, because the image will change back to the default pin as soon as you start dragging. Therefore I use an MKAnnotationView instead of an…
Pieter
  • 1,751
  • 3
  • 30
  • 65
8
votes
1 answer

Change the image's origin of map annotation view?

The regular annotation pin's origin is in the middle of the bottom so, the pin always point to the same place. But when I add my custom image, its origin is the center of the image, so every zoom in or out, the bottom of my image point to a…
AMTourky
  • 1,190
  • 13
  • 25
7
votes
6 answers

Resize MKAnnotationView Image When map zooms in and out?

What i have I have about 150 MKAnnotationViews on a map. Every MKAnnotationView has an image that replaces the default pin. What's happening now When the map zooms in, the MKAnnotationViews are getting smaller and the opposite when it zooms…
shannoga
  • 19,649
  • 20
  • 104
  • 169
7
votes
4 answers

Putting UIButton and other UIControl objects inside an MKAnnotationView and allowing user interaction

I have a custom annotation view on the map, which has a UIButton in it, but the UIButton is not responsive when pressed. I have two main problems with user interaction on the annotation view: Buttons and other controls are not responsive. I want…
jhabbott
  • 18,461
  • 9
  • 58
  • 95
7
votes
1 answer

MKMapView not Clustering Annotation on zooming out map in Swift

before duplicating my questing please read the whole thing. i am using MkMapKit in my app and now I have to show people in cluster when zoom out the map, I have achieved numbering them out so far using from this answer using Apple's default…
Ahsan
  • 95
  • 1
  • 10
7
votes
0 answers

change title font of map callouts swift

I would like to know if there is any way to change title font without creating a custom view? Something like this: annotation.title.font = UIFont.systemFontOfSize(12.0) I searched around, everyone says that I have to create a custom view like this…
Chongzl
  • 589
  • 1
  • 9
  • 25
7
votes
2 answers

Handling overlapping MKAnnotationView(s)

How can we ensure that the annotation views are placed in a specified order/ position on the map? I have a case where a single address can have multiple annotations (on top of each other). For example, Pin numbers 1, 2, 3, and 4 are placed at the…
Mustafa
  • 20,504
  • 42
  • 146
  • 209
7
votes
3 answers

UIImageView as callout's leftCalloutAccessoryView automatically shifts top-left corner

It works great on iOS 7 but UIImageView's position shifts on iO8 like images below. Also rightCalloutAccessoryView position shifts top-right corner. Can anybody help? Cheers. In iOS 7 In iOS 8 -(void)mapView:(MKMapView*)mapView…
7
votes
1 answer

How do i get an MKAnnotationView's coords?

I have a method like this: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control Using this, can i get the coordinates?
tarnfeld
  • 25,992
  • 41
  • 111
  • 146