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
27
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,…
Stijn
  • 858
  • 2
  • 12
  • 21
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
  • 1,016
  • 1
  • 11
  • 27
27
votes
5 answers

Determining Midpoint Between 2 Coordinates

I am trying to determine the midpoint between two locations in an MKMapView. I am following the method outlined here (and here) and rewrote it in Objective-C, but the map is being centered somewhere northeast of Baffin Island, which is no where…
Mike D
  • 4,938
  • 6
  • 43
  • 99
26
votes
9 answers

why self.locationManager stopUpdatingLocation doesn't stop location update

Problem: It seems I can't stop Core Location from sending updates to my app / tracking. What am I doing: In my viewWillAppear I call self.locationManager and pass it to a method to show user's location on the map (an instance of MKMapView). The…
Sierra Alpha
  • 3,707
  • 4
  • 23
  • 36
26
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,682
  • 3
  • 26
  • 39
26
votes
3 answers

Custom MKAnnotation callout bubble with button

I'm developing app, where user is localized by gps and then he is asked, whether he is located in specific place. To confirm this, callout bubble is presented to him straight away, asking him, if he is at specific place. As there is alot of similar…
Yanchi
  • 1,030
  • 1
  • 20
  • 31
26
votes
10 answers

Zoom in a MKMapView programmatically

I'm using a MKMapView inside an iPhone app. When I click a button the zoom level must increase. This is my first approach: MKCoordinateRegion zoomIn = mapView.region; zoomIn.span.latitudeDelta *= 0.5; [mapView setRegion:zoomIn…
Hectoret
  • 3,553
  • 13
  • 49
  • 56
25
votes
1 answer

UIImage(contentsOfFile:) returning nil despite file existing in caches directory

I'm trying to save a snapshot of a map with an overlay in the caches directory and retrieve it when it exists. However, despite the file being created, UIImage(contentsOfFile:) returns nil when I try to retrieve it. I've printed the file paths for…
doovers
  • 8,545
  • 10
  • 42
  • 70
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
  • 515,959
  • 87
  • 875
  • 1,141
25
votes
2 answers

How can I know when MKMapview setRegion:animated: has finished?

I want to set a region on my MKMapView and then find the coordinates corresponding to the NE and SW corner of the map. This code works just fine to do that: //Recenter and zoom map in on search location MKCoordinateRegion region = {{0.0f, 0.0f},…
deadroxy
  • 1,699
  • 2
  • 17
  • 22
25
votes
8 answers

iPhone: Detecting Tap in MKMapView

How do I detect a single tap on an instance of MKMapView? Do I have to subclass MKMapView and then override the touchesEnded method? Thanks, -Chris
ChrisJF
  • 6,822
  • 4
  • 36
  • 41
24
votes
3 answers

Displaying a Map with MapKit in a Swift playground for a Quick Look?

Good to see a tag for swift-playground - love to see this continue. I've been tinkering with Swift and am wondering whether the MapKit can be used in the playground so that you can use the Quick Look feature so I can iterate and play around with a…
Kokanee
  • 975
  • 4
  • 9
  • 20
24
votes
4 answers

Why am I crashing after MKMapView is freed if I'm no longer using it?

I have a MKMapView. Sometimes after my view controller is dismissed, I'll get a EXC_BAD_ACCESS. I turned on NSSZombies and it looks like the MKMapView's delegate — my view controller! — is being called, despite both the MKMapView and…
Steven Fisher
  • 44,462
  • 20
  • 138
  • 192
24
votes
5 answers

How can I create a custom "pin-drop" animation using MKAnnotationView?

I have an instance of MKMapView and would like to use custom annotation icons instead of the standard pin icons supplied by MKPinAnnotationView. So, I've setup a subclass of MKAnnotationView called CustomMapAnnotation and am overriding…
user226010
24
votes
5 answers

I want to get the Location name from the Coordinate value in MapKit for iPhone

I want to get the location name from the coordinate value. Here is code, - (void)viewWillAppear:(BOOL)animated { CLLocationCoordinate2D zoomLocation; zoomLocation.latitude = 39.281516; zoomLocation.longitude= -76.580806; …
Apple
  • 736
  • 1
  • 6
  • 24