Questions tagged [mapkit]

MapKit is Apple's framework for presenting and annotating scrollable and zoom-enabled maps on iOS, IPadOS, tvOS, watchOS, and macOS.

MapKit is Apple's framework for presenting and annotating maps for iOS, IPadOS, tvOS, watchOS, and macOS. Maps are rendered via the MKMapView control, which offers scrolling, zooming, and optionally real-time highlighting of the user's current location on both traditional maps as well as satellite imagery.

Maps can be further customized by:

  • Adding annotations (information about a point on the map), which can then be represented on the MKMapView using annotation views, graphical representations (such as a drop pin or a custom image). Annotations also may have associated attributes (such as text that can appear in a callout box that appears when you tap on an annotation view), and these callout boxes can also have additional behaviors (e.g. left and right accessory controls that you can use to perform custom operations, etc);

  • Adding overlays, graphical representations between a collection of map points (e.g. a MKPolyline that represents one or more line segments, such as a path, along the map; a MKPolygon that represents a shaded portion of the map defined by the coordinates of a polygon, a MKCircle that represents a shaded circle around a particular map point, etc.). Overlays are represented by MKOverlayView objects which define the particulars of how the overlay is represented (line thickness, line color, shading, etc.).

  • The Map Kit framework also provides local search capabilities (as of iOS 6.1, OS X 10.9), via MKLocalSearch, which will asynchronously return establishments and points of interest based upon the search criteria.

The reverse geocoding, via MKReverseGeocoder, is deprecated as of iOS 5.0, superseded by the CLGeocoder class of the Core Location framework

MapKit is part of the following SDKs:

  • iOS 3.0 and later,
  • macOS 10.9 and later,
  • Mac Catalyst 13.0 and later,
  • tvOS 9.2 and later,
  • watchOS 2.0 and later.

###Related tags:

###References:

5877 questions
39
votes
11 answers

How to move a MKAnnotation without adding/removing it from the map?

Is it possible to move the coordinate of a MKAnnotation without adding and removing the annotation from the map?
DevDevDev
  • 5,107
  • 7
  • 55
  • 87
39
votes
10 answers

Getting the bounds of an MKMapView

In order to setup a query to an external server I want to get the bounds of the current Map View in an iPhone app I'm building. UIView should respond to bounds but it seems MKMapView doesn't. After setting a region and zooming in the map I try to…
deadroxy
  • 1,699
  • 2
  • 17
  • 22
39
votes
9 answers

MKPinAnnotationView: Are there more than three colors available?

According to the Apple docs, MKPinAnnotationView's pin color is available in red, green and purple. Is there any way to get other colors also? I've found nothing in the docs.
Stefan
  • 28,843
  • 15
  • 64
  • 76
39
votes
7 answers

How to define the order of overlapping MKAnnotationViews?

I have several MKAnnotations (and their corresponding views) in my map, and it sometimes gets really crowded. Now, the annotations in my app come in two flavors: some are bound to stay where they are, while others will move as time goes on. I'd…
user140383
38
votes
9 answers

Z-index of iOS MapKit user location annotation

I need to draw the current user annotation (the blue dot) on top of all other annotations. Right now it is getting drawn underneath my other annotations and getting hidden. I'd like to adjust the z-index of this annotation view (the blue dot) and…
jmcopeland
  • 1,216
  • 2
  • 12
  • 21
38
votes
7 answers

iOS 8 MKAnnotationView rightCalloutAccessoryView misaligned

I'm still pretty new to the iOS stuff in general and found a problem while testing our App for iOS 8 compatibility. In iOS 7 everything worked fine but on iOS 8 the rightCalloutAccessoryView is misaligned under certain circumstances. First…
byemute
  • 643
  • 7
  • 15
38
votes
4 answers

kCLErrorDomain error 2 after geocoding repeatedly with CLGeocoder

I have a search bar in my application that the user can type an address into, and it will come up with the geocoded result. The result updates as the user types, according to the following code: - (void)searchBar:(UISearchBar *)searchBar…
jburns20
  • 3,147
  • 2
  • 26
  • 32
38
votes
4 answers

How to disable user interaction on MKMapView?

How do you disable user interaction to an entire Map (MKMapView) in iOS? I just want to disable zooming, tapping, etc and show a static map. [self.mapView setUserInteractionEnabled:NO] didn't work. Found no working solutions via Google or other…
eric
  • 4,863
  • 11
  • 41
  • 55
37
votes
8 answers

Compiler error: Invalid library file - CoreLocation

I have one of my application, that is created in Xcode 8. I have used CoreLocation and MapKit in that app. I have update app with latest iOS till now. and it was working fine. Now I am updating application with iOS 1. So I hvae opened app with Xcode…
VRAwesome
  • 4,721
  • 5
  • 27
  • 52
37
votes
4 answers

How to create an MKMapRect given two points, each specified with a latitude and longitude value?

I have a custom class that extends NSObject and implements the MKOverlay protocol. As a result, I need to implement the protocol's boundingMapRect property which is an MKMapRect. To create an MKMapRect I can of course use MKMapRectMake to make one.…
John Erck
  • 9,478
  • 8
  • 61
  • 71
37
votes
8 answers

Centering MKMapView on spot N-pixels below pin

Want to center MKMapView on a point N-pixels below a given pin (which may or may not be visible in the current MapRect). I've been trying to solve this using various plays with -(CLLocationCoordinate2D)convertPoint:(CGPoint)point…
eric
  • 4,863
  • 11
  • 41
  • 55
36
votes
5 answers

How do I remove all map annotations in swift 2

I had working code to remove all map annotations with a button, but after my update to xcode 7 I am running into the error: Type 'MKAnnotation' does not conform to protocol 'SequenceType' if let annotations = (self.mapView.annotations as?…
user4812000
  • 1,033
  • 1
  • 13
  • 24
35
votes
3 answers

MapKit not showing custom Annotation pin image on iOS9

My code worked fine from iOS 7 to 8. With the update yesterday the custom images on my pins were replaced by the standard pin image. Any suggestions? My code: extension ViewController: MKMapViewDelegate { func mapView(mapView: MKMapView,…
Felix Weber
  • 518
  • 1
  • 4
  • 8
35
votes
1 answer

Alert view disappears on its own when calling [locationManager requestWhenInUseAuthorization];

I'm calling [locationManager requestWhenInUseAuthorization]; on a screen that shows an MKMapView (showsUserLocation = YES). Which seems weird in the first place (Apple should handle this for MKMapView automatically, but XCode was complaining when I…
Fraggle
  • 8,607
  • 7
  • 54
  • 86
34
votes
4 answers

How to draw a route between two locations using MapKit in Swift?

How can I draw a route between user's current location to a specific location using MapKit in Swift? I searched a lot, but didn't find any helpful Swift-specific links or tutorials.
Rawan
  • 1,589
  • 4
  • 23
  • 47