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

How to fix custom Point Annotations from disappearing from overlap?

Attempting to show custom point annotations from MapKits local search. When the annotations first load on the map all of them show, but then the overlapping ones disappear. And they only reappear when you zoom in on the area. Many stack solutions…
JayPhipps
  • 23
  • 4
2
votes
1 answer

swift 4 Annotation from json not visible until user drags on map

I am having problems showing the annotations on the map. They only show when I move or drag the map. I tried to follow tutorial on youtube and also one of the questions which is c sharp Please can sone one help .. here is the code Here I created a…
hesh
  • 65
  • 4
  • 12
2
votes
1 answer

MapKit custom image for multiple annotations

I have news objects and I want to customize the news annotation according to the news category. Without the switch statement, if I just write annotationView?.image = UIImage(named: "ic_sports"), all annotations; images shows the sport image. How can…
Jumana Alhaddad
  • 285
  • 2
  • 6
  • 17
2
votes
1 answer

How to draw circle overlay on MapKit that surrounds several annotations/coordinates?

I have an array [CLLocationCoordinate2D], I would like to draw a circle on MKMapView surrounding all these coordinates. I have managed to draw a circle around a single CLLocationCoordinate2D as such: let coordinate = CLLocationCoordinate2D(latitude:…
AamirR
  • 11,672
  • 4
  • 59
  • 73
2
votes
1 answer

Trouble creating custom MKAnnotationView

I'm having a hard time displaying a custom annotation view. Specifically, I'm trying to set an image named "pin" to be the new map pin. The default pin always shows. I've been making small changes for a few hours to no avail, such as changing "pin"…
Cody Potter
  • 160
  • 1
  • 11
2
votes
2 answers

Creating a custom map annotation callout with an image, accessing data from an array

I have a parsed a set of data from a JSON file (see example below): { "locations": [ { "id": "0001", "name": "Helensburgh Tunnels", "type": "Tunnels, Beach, Views", "location":…
joshlorschy
  • 105
  • 1
  • 2
  • 15
2
votes
1 answer

Update MKPointAnnotation object while dragging

I want to know how to update my annotation title while i am dragging it because all the annotation properties are get only. Code I have try: func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, didChange newState:…
ankit
  • 3,537
  • 1
  • 16
  • 32
2
votes
3 answers

SWIFT 2: multiline MKPointAnnotation

Is there a way to create multiline annotations? Here is my code: 1) My customAnnotation class import UIKit import MapKit class CustomAnnotation: NSObject, MKAnnotation { var title: String? var subtitle: String? var address: String =…
Almazini
  • 1,825
  • 4
  • 25
  • 48
2
votes
1 answer

how can I add an annotation view to the pin on my apple map while using marker clustering in swift?

I'm using a simple marker cluster taken from here https://github.com/ribl/FBAnnotationClusteringSwift and I see this part of code responsible for putting on the map either a cluster or a pin: func mapView(mapView: MKMapView!, viewForAnnotation…
user3766930
  • 5,629
  • 10
  • 51
  • 104
2
votes
1 answer

Change color pin iOS 9 Mapkit

I don't know how to change the code for the pin color in iOS 9 (because lately Apple changed the code for it), and I'm still new in Swift. So, I don't know how to integrate pinTintColor in my code now. Please find below my code: import UIKit import…
user5370095
2
votes
0 answers

Map kit Custom PopupView instead of callout Bubble view IOS Swift

I want to show some details, contain an image and related details when i click on the pin . i don't know how to customise bubble view.Can any one help me to find out a solution for this will be helpful. Code below i tried but height is fixed not…
2
votes
2 answers

Swift/iOS MapKit function on MKAnnotation tap

I have a map and I have added 12 Annotations to it perfectly, what I would like is so that when someone taps on these Annotations it would have an info button to the right of the annotation which when tapped would show directions to the annotation…
user4011770
  • 29
  • 1
  • 4
2
votes
2 answers

string under Map Kit pin (mkannotationview image)

I am trying to set names under pins that are on a map. Each name should be specific. I am not using default pins, hence each pin is a specific image. I was thinking of generating some kind of image that would present the image of the pin and the…
Quentin Malgaud
  • 405
  • 6
  • 21
2
votes
2 answers

How to display title for multiple annotations directly when map loaded

I am loading Multiple annotations onto my map view. These annotations displays as a pin when the map is loaded. By using the below code i can display title directly for one annotation, but for remaining annotations user is required to tap on the pin…
1
vote
1 answer

SwiftUI MapKit - MapAnnotation - cause so many view updates errors - Can we use it in Production release?

I want to use MapKit along with MapAnnotation in SwiftUI. So I can have custom views as map pins and add tap gestures to them later. But when I run the app, Xcode starts to show so many UI errors: Publishing changes from within view updates is not…
Sajjad Sarkoobi
  • 827
  • 8
  • 18
1 2
3
17 18