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

how to display data from plist in detail view using segue when map view annotation is pressed

as the title describes i am having trouble displaying the data that i have in my plist for annotations in the map view project i am working on using segue in storyboard. i have the map view and all the annotations (pins) are showing their co…
Adrian P
  • 6,479
  • 4
  • 38
  • 55
-1
votes
1 answer

How to make a view conform to MapAnnotationProtocol

I have a tappable MapAnnotation and whenever I try to customize the "look" of the annotation pin, I get the following error: Initializer 'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:annotationItems:annotationContent:)'…
SwiftX
  • 78
  • 6
-1
votes
1 answer

SwiftUI MapKit - Multiple annotations in same map

I've had a look at similar questions but nothing seems to answer this question exactly. I have a Map view and I want to add pin overlays, as well as a poly line route overlay on top of it. I am very very new at SwiftUI dev (this is my first app), so…
AAH
  • 99
  • 1
  • 10
-1
votes
1 answer

Custom annotation on the map

I have an app where the user presses a button and takes a photo, then the photo goes to ImageAnnotation class and it must be added to the map, but I get such an error: "Unexpectedly found while implicitly unwrapping the optional" Only this error…
Noir3
  • 1
  • 3
-1
votes
1 answer

Swift/MapKit - Annotations overlapping one another

I'm using MapKit in my project and everything works perfectly. However, I've noticed an issue, annotations may appear over one another, if the longitude and latitude are the same which is understandable. However, as a result, this renders some…
SwiftUser
  • 555
  • 6
  • 17
-1
votes
1 answer

MapKit/MKMapViewDelegate on didSelect: bottom sheet doesn't open if user location is enabled

I'm trying to rebuild Apple Maps's annotation selection behaviour on iOS. If I click on a map pin it should open a bottom sheet with further information about the place. While already having coded all basic components my bottom sheet doesn't open if…
-1
votes
1 answer

Mapkit get current coordinates of placemarker

I am fairly new to MapKit and am attempting to show information and directions once the place marker is selected. I am displaying local hospitals and emergency services. How do I get the information of the currently selected placemarker. I want to…
ppApp
  • 11
  • 4
-1
votes
1 answer

How do I specify which button was clicked when calling the "calloutAccessoryControlTapped" method in MapKit? Swift 4

I have two buttons on the two sides of my annotationView and would like them to execute different methods depending on which one is clicked. I used the calloutAccessoryControlTapped for the first button, but do not know how to specify a method for…
-1
votes
1 answer

Crashing MapKit

I am currently working on a MapKit app, which puts custom annotations (locations) on a MapKit MapView. However, something is going wrong with placing the pins. The pins are in fact displayed on the map and such, but the app kept crashing. So I ran…
Jamie Coenen
  • 75
  • 1
  • 10
-1
votes
1 answer

how to show longitude, latitude in label of this same code

//ViewController.h #import #import #import @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UILabel…
NARAYAN
  • 1
  • 3
-1
votes
1 answer

Saving Annotations on MapView

Currently the app I am developing creates custom annotations, but when the user switches away from the page with the mapView they are all unloaded. I am saving them into a custom array but UserDefaults is not letting me save that array. Is there an…
-1
votes
1 answer

How do I transfer the information stored in a MapKit Annotation to a new view controller while using prepareSegue

I download some info from Firebase and store that info into my custom annotation class. Then I want to transfer that info to variables on the next view controller so that the table view can properly load. instead of crashing because values are…
Taylor Simpson
  • 940
  • 1
  • 10
  • 27
-2
votes
1 answer

How show map annotations when map span will be 0.1?

How show map annotations when map span will be 0.1? I want map pins to not show until map span is <= 0.1 struct City: Identifiable { let id = UUID() let name: String let coordinate: CLLocationCoordinate2D } struct ContentView: View { …
-2
votes
1 answer

Add title and subtitle to associated annotations in swift 4

I'm showing an array of annotations in a map view and need to have the corresponding title and subtitle with each annotation. My current code only gets me the 1st title/subtitle on all of the annotations. func multiPoint() { var…
jvan
  • 173
  • 1
  • 9
-2
votes
1 answer

Change Pin's color in MapKit - Swift 4 - Xcode 10 - iOS 12

I am trying to change the color of the pin used in my map in MapKit in Xcode. I found this in the Apple Developer Documentation: Declaration (iOS, tvOS): var pinTintColor: UIColor! { get set } I am new to code and I can't figure out what I should…
Eric
  • 1
  • 1
  • 1
1 2 3
17
18