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
23
votes
5 answers

Gradient Polyline with MapKit ios

I'm trying to trace a route on a MKMapView using overlays (MKOverlay). However, depending on the current speed, I want to do something like the Nike app with a gradient while tracing the route, if the color is changing (for example, from green to…
Dachmt
  • 2,079
  • 4
  • 29
  • 45
23
votes
1 answer

Search for Place Names (City/Town) Using MKLocalSearchCompleter

I'm trying to build a autocomplete textfield which needs to display the city/town name only. So what I want to do is that when someone enters Am it will show Amsterdam Amstelveen So it will only display the actual city names and nothing beyond…
NoSixties
  • 2,443
  • 2
  • 28
  • 65
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
  • 649
  • 1
  • 7
  • 22
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
  • 15,187
  • 13
  • 60
  • 91
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
22
votes
6 answers

iOS: Notification when MKMapView is loaded and annotations/overlays are added?

I am aware of the delegate methods used to let me know when the map has loaded and annotations and overlays have been added. (mapViewDidFinishLoadingMap: mapView:didAddAnnotationViews: mapView:didAddOverlayViews:) I am wanting to create a UIImage…
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
22
votes
2 answers

MKOverlay not resizing smoothly

I have added a MKCircle as MKOverlay to my MKMapView. Also I added an UISlider to decide the radius of the circle. Unfortunately when using this it seems a bit "laggy", not smootly like I want it to…
Paul Peelen
  • 10,073
  • 15
  • 85
  • 168
22
votes
1 answer

put CLLocationCoordinate2D into CLLocation for Swift

I have a method I want to call however when I get back the center of the map, it is in CLLocationCoordinate2D type. How do I put the results of CLLocationCoordinate2D into CLLocation?
22
votes
2 answers

how to highlight countries in ios maps

I am building an app in which I have to highlight some countries dynamically in the world map. In short I want to customize the whole view of ios maps as shown in the images. can this be done using MapKit or is there any other method. Thanks in…
Rajesh
  • 937
  • 1
  • 8
  • 14
22
votes
7 answers

How do i open Google Maps for directions using coordinates on the iphone

I am using UIMapView to display locations on the iPhone. I want to do a directions from current location to the location of interest, I don't think its possible using MapKit (but if it is please inform) So I will open either the Google Maps…
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
21
votes
2 answers

How to check if Apple Maps is installed

Anyone aware how to check whether Apple Maps is installed or not? I could not find anything in the docs. With iOS10 users can delete the Apple Maps application. While for Google Maps we can use UIApplication.shared.canOpenURL() to check if it's…
tcurdt
  • 14,518
  • 10
  • 57
  • 72
21
votes
7 answers

MKMapView setRegion "snaps" to predefined zoom levels?

Can anyone confirm that setRegion "snaps" to predefined zoom levels and whether or not this behavior is as designed (although undocumented) or a known bug? Specifically, it appears that setRegion snaps to the same zoom levels that correspond to the…
charshep
  • 416
  • 4
  • 14
21
votes
4 answers

MapKit iOS 9 detailCalloutAccessoryView usage

After watching WWDC video 206 I assumed this would be a trivial task of adding the detail callout view to a mapView annotation view. So, I assume Im doing something wrong. With my pin view set up func mapView(mapView: MKMapView, viewForAnnotation…
DogCoffee
  • 19,820
  • 10
  • 87
  • 120
21
votes
6 answers

detect if a point is inside a MKPolygon overlay

I want to be able to tell if tap is within a MKPolygon. I have a MKPolygon: CLLocationCoordinate2D points[4]; points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116); points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066); points[2]…
Padin215
  • 7,444
  • 13
  • 65
  • 103
20
votes
3 answers

How to update UIViewRepresentable with ObservableObject

I'm trying to learn Combine with SwiftUI and I'm struggling how to update my view (from UIKit) with ObservableObject (previously BindableObject). The issue is that, obviously, method updateUIView will not fire once the @Published object sends the…
Nat
  • 12,032
  • 9
  • 56
  • 103