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
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,609
  • 2
  • 17
  • 22
25
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,020
  • 1
  • 21
  • 30
25
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,455
  • 13
  • 45
  • 53
24
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…
Canopus
  • 3,627
  • 4
  • 19
  • 35
24
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:…
Mc.Lover
  • 5,536
  • 21
  • 82
  • 152
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
  • 935
  • 3
  • 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
  • 43,056
  • 20
  • 131
  • 184
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
  • 740
  • 1
  • 5
  • 23
24
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,788
  • 6
  • 42
  • 94
23
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,426
  • 3
  • 24
  • 42
23
votes
6 answers

Swift - CLGeocoder reverseGeocodeLocation completionHandler closure

What I'm trying to do is pass a CLLocation to the function getPlacemarkFromLocation which then uses the passed CLLocation through reverseGeocodeLocation to set the CLPlacemark? that will be returned. I'm having issues creating the completionHandler…
AaronDancer
  • 640
  • 1
  • 5
  • 21
23
votes
8 answers

iPhone Map Kit cluster pinpoints

Regarding iPhone Map Kit cluster pinpoints: I have 1000's of marks that I want to show on the map but it's just too many to handle so I want to cluster them. Are there frameworks available or proof of concepts? That this is possible or is already…
Andy Jacobs
  • 14,897
  • 13
  • 57
  • 89
23
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,032
  • 4
  • 31
  • 36
23
votes
4 answers

MapView in iOS6 won't show certain zoom levels at latitude > 75 north

This code sets a default zoom level centered around a specified location in viewDidLoad. The code works fine in previous versions of iOS: CLLocationDistance visibleDistance = 100000; // 100 kilometers MKCoordinateRegion region =…
Neur0mans3r
  • 231
  • 2
  • 3