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:

5649 questions
30
votes
7 answers

How do I animate MKAnnotationView drop?

I have a custom MKAnnotationView where I set my image myself in viewForAnnotation. How do I animate it's drop like I can with MKPinAnnotationView? My code is - (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id…
30
votes
4 answers

Calculate new coordinate x meters and y degree away from one coordinate

I must be missing somthing out in the docs, I thought this should be easy... If I have one coordinate and want to get a new coordinate x meters away, in some direction. How do I do this? I am looking for something like -(CLLocationCoordinate2D)…
Nicsoft
  • 3,544
  • 8
  • 38
  • 70
30
votes
3 answers

MKAnnotationView - Lock custom annotation view to pin on location updates

Update #5 I guess it's bounty time. 100+ views and no one's taken a stab, even with the code sample I've posted. How about some reputation points! Update #4This is a pretty complicated question, so I created a new tab based project which just…
djibouti33
  • 11,832
  • 9
  • 75
  • 111
30
votes
8 answers

CLLocation Category for Calculating Bearing w/ Haversine function

I'm trying to write a category for CLLocation to return the bearing to another CLLocation. I believe I'm doing something wrong with the formula (calculous is not my strong suit). The returned bearing is always off. I've been looking at this question…
Nick
  • 8,383
  • 10
  • 43
  • 63
30
votes
4 answers

iOS + MKMapView user touch based drawing

I have searched a lot for this question, but none of them seem to do exactly what I want. A lot of tutorials show me how to add lines and polygons in code, but not with freehand drawing. The question is the following one: I am building a real estate…
krswtjns
  • 321
  • 4
  • 4
30
votes
3 answers

Google Places API Violation

I am using Google Places API to pull a list of resturants, and I am displaying them on map. However, since Apple has switched there map services over from Google in iOS 6.0, I am now in violation of Google's terms of use, which states that you must…
Vikings
  • 2,517
  • 30
  • 45
30
votes
7 answers

Wanted: How to reliably, consistently select an MKMapView annotation

After calling MKMapView's setCenterCoordinate:animated: method (without animation), I'd like to call selectAnnotation:animated: (with animation) so that the annotation pops out from the newly-centered pushpin. For now, I simply watch for…
Joe D'Andrea
  • 5,101
  • 6
  • 46
  • 67
28
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,419
  • 4
  • 22
  • 43
28
votes
3 answers

How to deal with inconsistent Chinese maps on iOS 6?

For Chinese maps on iOS 6, it seems that MapKit selects map provider based on your where the device is located. If you're in China it will use AutoNavi maps, and else it will use the default Apple maps. To complicate things, the AutoNavi maps seem…
Anton
  • 5,521
  • 5
  • 31
  • 51
27
votes
2 answers

Adding Pins to Map using MapKit - Swift 3.0

New coder, trying to figure out how to use MapKit. The goal is to create a map that users can add pins to using their address. However, the step I am at now, I am having trouble figuring out how to add pins to the map at all. How can I add a pin to…
roguephillips
  • 271
  • 1
  • 3
  • 4
27
votes
7 answers

iOS6 Simulator MKMapKit "Couldn't find default.styleproto in framework"

Running my app with the iOS6 simulator I am getting the following printed in the XCode console prior to viewDidLoad getting called: Couldn't find default.styleproto in framework Has anyone else encountered this, and if so have you found a reason…
abellina
  • 989
  • 1
  • 10
  • 27
26
votes
2 answers

How to open call out MKAnnotationView programmatically? (iPhone, MapKit)

I want to open up the callout for an MKPinAnnotationView programmatically. Eg I drop 10 pins on the map, and want to open up the one closest to me. How would I go about doing this? Apple has specified the 'selected' parameter for MKAnnotationView's,…
StijnSpijker
  • 827
  • 2
  • 12
  • 21
26
votes
7 answers

Remove markers from google maps iOS

I am building an iOS app using storyboards and Google Maps. Using iOS6 My application features the split view navigation as seen in the facebook app On my left view I am selecting an item in a list which has lat/long cords and showing it on my map…
jchri853
  • 324
  • 1
  • 4
  • 11
25
votes
1 answer

Animate MapKit annotation coordinate change in Swift?

When using MapKit in iOS 8 in Swift, how do I make it possible to animate a change in the map position of a custom annotation? I am saying this: UIView.animateWithDuration(0.25) { var loc = ann.coordinate loc.latitude = loc.latitude +…
matt
  • 447,615
  • 74
  • 748
  • 977
25
votes
8 answers

Detecting touches on MKOverlay in iOS7 (MKOverlayRenderer)

I have an MKMapView with possibly hundreds of polygons drawn. Using MKPolygon and MKPolygonRenderer as one is suppose to on iOS7. What I need is a way of acting upon the user touching one of the polygons. They represent an area on the map with a…
manecosta
  • 8,106
  • 3
  • 23
  • 37