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

Correctly resize MapKit map annotation pin

I have a map with several annotation pins added. What I want to achieve is, when one of the pins is tapped, the pin enlarges. I have the following code snippet func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView){ if(view.image…
Wesley Skeen
  • 1,164
  • 3
  • 14
  • 22
3
votes
1 answer

MapKit not removing all annotations

MapKit seems to have a strange issue!!! I have some code that adds some annotations and then I call NSArray *existingpoints = mapView.annotations; [mapView removeAnnotations:existingpoints]; if ([mapView.annotations count] > 0) { …
Lee Armstrong
  • 11,420
  • 15
  • 74
  • 122
3
votes
1 answer

Reliably retrieve MKAnnotationView for MKAnnotation

I can get an annotationView from an MKMapView by simply passing it an annotation: view(for annotation: MKAnnotation) -> MKAnnotationView? That returns an optional, because if an annotation is offscreen, it might not have an associated…
djibouti33
  • 12,102
  • 9
  • 83
  • 116
3
votes
1 answer

Mapkit annotation anchor point

I'm using a custom image for MapKit annotations using : func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {} The "pin" shows with the right image now when I add a new annotation to my map, but it seems to use…
Gavin Beard
  • 199
  • 2
  • 12
3
votes
1 answer

How to rotate custom userLocationAnnotationView image using MapKit in swift?

I'm trying to find a way to show the direction of the user on the map using MapKit. The native MapKit way to do that always rotate the entire map. Since user position is also an MKAnnotationView, I decided to create a specific class to override it…
iji
  • 392
  • 1
  • 2
  • 13
3
votes
1 answer

How to resize callout bubble after resetting title/subtitle

I created an MKAnnotation name PushPin which has a title and subtitle. I want to be able to dynamically change the title at a later time. I'm close so I'd rather not have to make a whole new AnnotationView, but if I have to I guess that's ok too. …
3
votes
0 answers

MapKit Display Annotation Clusters and Along With Non-Clustered Annotations

I am new to iOS development and currently using the FBAnnotationClusteringSwift to cluster makers. My app needs to have two annotations which will not be clustered, as they indicate the source and destination addresses. The remaining annotations…
Eduardo
  • 4,282
  • 2
  • 49
  • 63
3
votes
1 answer

Swift, How to get information from a custom annotation on clicked

I've got the following custom annotation class: import UIKit import MapKit class LocationMapAnnotation: NSObject, MKAnnotation { var title: String? var coordinate: CLLocationCoordinate2D var location: Location init(title: String,…
Big Green Alligator
  • 1,175
  • 3
  • 17
  • 33
3
votes
1 answer

How to override "selected state" image in MKAnnotationView?

I've got annotation views with custom pin images on a map. When I tap and hold on a pin, my custom image disappears and is replaced by the default red pin. This default image appears in its selected (highlighted) state (it looks slightly darker).…
cravr
  • 467
  • 1
  • 4
  • 12
3
votes
3 answers

Update image for user location on MKMapView

Im setting a custom image for the user location on a map like this: func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { if annotation.isEqual(mapView.userLocation) { let identifier =…
3
votes
1 answer

MKAnnotationView not Removing from MKMapView

I have a simple array or MKAnnotations for location objects that are fetched from CoreData upon view load. When I remove a location object, I also manually remove the location object from the array. After removing from array I call…
Bren
  • 332
  • 1
  • 2
  • 13
3
votes
1 answer

Displaying geopoint of all users in a map parse

I'am trying to query an array of PFGeoPoints stored on the Parse backend. I have the User table, with data assigned to it such as "location", "name". everything is being sent to Parse upon posting from my app and is properly stored in the backend. I…
Mams1101
  • 53
  • 9
3
votes
1 answer

MapView with clusters: how to display multiple annotations on same view

I have integrated FBAnnotationClustering on mkmapview which works perfectly, but when there is more than one annotation at exactly the same place I cannot display the annotationView with the correct informations. I'm trying to loop through the…
Kalianey
  • 2,738
  • 6
  • 25
  • 43
3
votes
1 answer

MKAnnotationView image with rotation

i would like add UIView to MKAnnotationView as image. But first I wanna rotation by degrees UIView and then add new UIImage to UIVIew. Can you help me? I tried but UIView never rotate. UIView *pinView = [[UIImageView alloc]…
3
votes
0 answers

Transform Annotationview based on user location heading direction

I am trying to transform annotationview based on user location heading direction.Annotation view not changing properly. LocationMapView.userTrackingMode=YES; locationManager.headingFilter =5; [locationManager…