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
32
votes
4 answers

Creating a new CLLocationCoordinate2D at custom Latitude/Longitude

I feel bad for asking this because it seems to be such a simple thing to get hung up on, but I've looked at every relevant resource I could, tried as many of the combinations for solutions that i've seen others use, and nothing has worked... I am…
Karoly S
  • 3,180
  • 4
  • 35
  • 55
31
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,644
  • 9
  • 41
  • 70
31
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
  • 311
  • 1
  • 3
  • 4
31
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,483
  • 10
  • 46
  • 65
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
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
  • 12,102
  • 9
  • 83
  • 116
30
votes
1 answer

How to fix terminal output of "Style Z is requested for an invisible rect" when moving view on default iOS Map, using MapKit and SwiftUI, Xcode 12

Using MapKit and SwiftUI (Version 12.0 beta 2 (12A6163b)) when zooming in/out around the map the terminal produces hundreds of these lines: 2020-07-21 21:05:39.310719-0500 MyApp[95733:4195994] [VKDefault] Style Z is requested for an invisible…
Mac Wayne
  • 587
  • 4
  • 13
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
  • 329
  • 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,527
  • 32
  • 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,141
  • 6
  • 49
  • 67
29
votes
2 answers

Subclassing MKGeodesicPolyline

I'm trying to subclass MKPolyline and MKGeodesicPolyline to store their own individual colours (by having the subclass instances return their own MKPolylineRenderer). It works fine for MKPolyline, but the instances of my MKGeodesicPolyline subclass…
Grimxn
  • 22,115
  • 10
  • 72
  • 85
29
votes
8 answers

MapKit zoom to user current location

I am trying to simply show user's location on the map, but I need to when app launches, the map should zoom to current location ,but I don't know why map doesn't zoom at all and it's like this : Here is the code : class MapViewController:…
iOS.Lover
  • 5,923
  • 21
  • 90
  • 162
28
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
  • 354
  • 2
  • 4
  • 12
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,932
  • 5
  • 36
  • 51
27
votes
7 answers

Check whether zoom level changed

I'm using MapKit on iPhone. How can I know when the user changes the zoom level (zoom in\out the map)? I've tried to use mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated; but that's called even when the map is only…
Rizon
  • 1,516
  • 4
  • 25
  • 45