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

Selecting a MapView Annotation Twice

My iPhone app has a mapview with a large number of locations that the user can select from. I would like him to be able to tap on one of the annotations to display its callout view, and then again to actually select it. The problem is that the…
Philip Sheard
  • 5,789
  • 5
  • 27
  • 42
5
votes
1 answer

iOS - Set Detail Disclosure Button on MKAnnotationView

I have the following method in my MapViewController: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation { MKAnnotationView *annotationView = [mapView…
8vius
  • 5,786
  • 14
  • 74
  • 136
5
votes
0 answers

How can I get the MKMarkerAnnotationView image?

I have created a map image using the MKMapSnapshotter. Unfortunately the snapshotter does not let you add annotations so I would like to add my annotation directly onto the view. I know for a pin you can do the following get the UIImage of the…
alionthego
  • 8,508
  • 9
  • 52
  • 125
5
votes
1 answer

MKAnnotationView is not getting displayed in iOS 11

I am having an application running on app store, which has map view with other functionality. Everything works perfectly till iOS 10 (all versions except iOS 11), now when I tested same app on iOS 11, then MKAnnotationView is not getting displayed…
iLearner
  • 1,670
  • 2
  • 19
  • 45
5
votes
2 answers

How to set custom pin image in Mapview swift ios?

@IBOutlet weak var map: MKMapView! override func viewDidLoad() { map.delegate = self showAlarms() super.viewDidLoad() // Do any additional setup after loading the view. } func showAlarms(){ map.region.center.latitude =…
Rakesh
  • 131
  • 2
  • 6
  • 14
5
votes
1 answer

iOS : Show the Callout view on moving pin

I have implement the same functionality as Uber iOS application for move the pin according to route with animation. Issues : When I click on the pin while it is moving then I am not able to get the didSelectAnnotationView delegate of the MKMapView.…
Ramkrishna Sharma
  • 6,961
  • 3
  • 42
  • 51
5
votes
4 answers

How to change default background color of callout bubble with detailCalloutAccessoryView

In my app I have the following sutuation. I've implemented a custom callout bubble with custom detailCalloutAccessoryView with two labels inside. I know how to change the color of detailCalloutAccessoryView with this line.…
Adelmaer
  • 2,209
  • 3
  • 22
  • 45
5
votes
2 answers

Subclass MKAnnotationView

Did somebody ever override successfully the method setDragState in MKAnnotationView? If I try to google for it with "mkannotationview setDragState" I only get three hits! One of them is my other post on stackoverflow ;) The reference says that when…
Ben Zwak
  • 225
  • 1
  • 3
  • 8
5
votes
1 answer

Only one (custom) annotation rotating from an array of other annotations

I am almost towards the last phase of my app, which shows a live map of buses. So, basically, I have a timer which gets the latitude and longitude of a bus periodically from a xml sheet which provides real-time locations of the buses. I was able to…
CocoaNuts
  • 179
  • 1
  • 13
5
votes
0 answers

Is there any way to change the height of the leftCalloutAccessoryView for a MKAnnotationView?

I want to display more than 2 lines of data in a callout. I now know that both the annotation title and subtitles are limited to 1 line each. Reading the following Apple documentation implies if you subclass MKAnnotationView and override…
nPn
  • 16,254
  • 9
  • 35
  • 58
5
votes
0 answers

ERROR: Trying to select an annotation which has not been added

[mapView selectAnnotation:firstAnnotation animated:YES]; After debug this line print below ERROR: Trying to select an annotation which has not been added Also viewForAnnotation is not called . What is the problem ? any solution ? Thanks in…
iApps
  • 59
  • 3
  • 8
5
votes
1 answer

How to rotate the navigation image according to the user direction in MKMapView?

I would like to show the user's current location while toggling Location mode on Free Ride in the Simulator. It's working fine, but take a look at the image below: I want this image to rotate as the direction of the route changes. How can I do…
user4790024
5
votes
1 answer

How to implement MKAnnotationViews that rotate with the map

I have an app with some annotations on it, and up until now they are just symbols that look good with the default behavior (e.g. like numbers and letters). Their directions are fixed in orientation with the device which is appropriate. Now however I…
Kurt
  • 4,477
  • 2
  • 26
  • 34
5
votes
1 answer

viewForAnnotation confusion and customizing the pinColor iteratively

The goal is to customize the pin colors per some values stored in an structure array. Per some help here I implemented the the following viewForAnnotation delegate method and that works great calling this delegate method iteratively in a loop based…
Kokanee
  • 975
  • 4
  • 9
  • 20
5
votes
1 answer

MKMapView -> display a button for my location

I have a MKMapView implemented with these lines of source code (my location is a blue bullet, the other one's are purple pins): - (MKAnnotationView *)mapView:(MKMapView *)mapViewLocal viewForAnnotation:(id )annotation { if…
Tim
  • 13,228
  • 36
  • 108
  • 159