Questions tagged [mapkitannotation]

MKAnnotation is the protocol that annotation objects must implement in order to be rendered on apple maps. The only absolute requirement is to provide a coordinate attribute. This is a CLLocationCoordinate2D object containing the latitude and longitude of your annotation.

The application obtains the data from a resource. This could be Core Data, a ReST call or any other suitable source. It is recommended that this be done on a background thread to not impact UI performance.

This data is then used to instantiate MKAnnotation objects. In addition to the required CLLocationCoordinate2D attribute a title can be supplied to display underneath the map pin. A subtitle will be displayed when the user selects the pin.

Annotations can be added individually or as an array to a MKMapView. The map will call its viewFor delegate when it is time to render the annotation. The application should attempt to dequeue an annotation view and if one is not available it should create a new one. This is the same paradigm used for table rows.

Finally assign the annotation to the AnnotationView. Additional options exist in MKMarkerAnnotationView to further customize e.g. changing the color of the marker pin.

Related tags:

References:

MKAnnotation

256 questions
1
vote
0 answers

MapKit MKMarkerAnnotationView subtitleVisibility in iOS 12

In an MKMarkerAnnotationView, when I set self.titleVisibility = .visible self.subtitleVisibility = .visible then title and subtitle are rendered below the marker. when I set self.titleVisibility = .adaptive self.subtitleVisibility = .adaptive then…
Gerd Castan
  • 6,275
  • 3
  • 44
  • 89
1
vote
1 answer

Get selected pin coordinate using MapKit framework (Objective-C)

I have a map region with about ten annotated MapPin objects (coordinates retrieved from a plist). In the code below 'locations' is a NSMutable array object containing the pin annotation latitude and longitude. for (int i = 0; i<[locations count];…
awyr_agored
  • 613
  • 3
  • 19
1
vote
1 answer

How to animate an MKMapKit annotation removal

Please can someone help with a MapView question. I have a custom annotation. When the user taps the annotation, I want it to move up the screen and then disappear. As a test of the animation code (as I am new to this!), I tried the following: func…
guinnessman
  • 433
  • 5
  • 15
1
vote
1 answer

How do I set the glyphimage of a MapKit annotation?

I know this is basic stuff but the documentation online is thin. I am new to Apple Mapkit and I am trying to create a simple annotation with a glyphImage overlay. I have the annotation working, but when I try to set the glyphImage the map blows up.…
1
vote
0 answers

Custom MKAnnotationView not staying centered on width change

I have an MKAnnotationView subclass being used to display information on a map. It has a UIImage as its background, and a UILabel on top of that image to display 4-5 characters of information. Sometimes I need to update the annotation in the…
Tejas Sharma
  • 462
  • 1
  • 4
  • 17
1
vote
2 answers

MKMarkerAnnotationView glyphimage doesn't display

I'm trying to scale a large image to fit in the glyphimage of a subclass of MKMarkerAnnotationView: class MyAnnotationView: MKMarkerAnnotationView { var database = MyDatabase() override var annotation: MKAnnotation? { willSet { …
Patrick
  • 261
  • 3
  • 16
1
vote
1 answer

MKAnnotationView: have texts below the annotationView and render the View

When I subclass MKMarkerAnnotationView, I get those nice text below the MarkerView for free, displaying title and subtitle. When I subclass MKAnnotationView, I am completely free how I render the annotationView: internal final class POIClusterView:…
Gerd Castan
  • 6,275
  • 3
  • 44
  • 89
1
vote
3 answers

Adding a title in front/below a custom annotation mapkit swift 4

In my app, I have a mapkit full of annotations and when one is clicked I want a new view to slide up with details on the annotation. Correct me if I'm wrong but I think you need to create a custom annotation in order to implement the didSelect()…
user9883052
  • 17
  • 1
  • 4
1
vote
0 answers

fix a MKPointAnnotation to centre of map (MapKit) even while user is scrolling

I need to fix an MKPointAnnotation to the center of the map even while the user is scrolling the map, it should still stay in middle. just like Ola app By far I achieved searching, setting annotation to the center of the map and changing annotation…
Tushar Katyal
  • 412
  • 5
  • 12
1
vote
2 answers

MapKit Direction to Selected annotation

Trying to get direction to selected annotation on the map from the current location of the User but not sure how to catch selected annotation(when user selecting one of them) and show direction.Checked different topics on the Stack but there is not…
Ula
  • 167
  • 1
  • 2
  • 11
1
vote
1 answer

How to do custom annotation view not find button click event?

I will try to find out of button click event in custom annotation view.How do it This.In In this not find out of button click event. Give some hint please. func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { let overlays…
B.Dhruvin
  • 31
  • 7
1
vote
2 answers

MapKit viewing angle

I am working on a program that should detect the pins on the map when the user is approaching to some distance, and the pin has to be in a certain angle of view. I have imported MapKit and added all pins to the annotation. Now my app is working but…
user8158114
1
vote
0 answers

Map Directions From Pins

Im creating a tagging app where users can tag Street Art to a map. I want users to be able to click on the pins (i) callout button and be taken to Apple Maps. This function should allow that to happen however I get an error "instance member…
1
vote
1 answer

I'm trying to draw polyline on coordinates(lat, long) coming from API using swift 3 in map kit but unable to make polyline

import UIKit import MapKit import CoreLocation import AddressBook class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate { @IBOutlet weak var TheMap: MKMapView! override func viewDidLoad() { …
1
vote
0 answers

XCode - Setting a Button as leftCalloutAccessoryView in MKAnnotationView

I'm attempting to set a button with the text "Button" as the left callout accessory view. Here is what I have so far func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { if let annotation = annotation as?…
S. Doe
  • 155
  • 1
  • 11