I'm trying to evaluate if we can support AR navigation with MapKit. The feature is supposed to be available for users in US.
I tried to run the sample on my iPhone: https://developer.apple.com/documentation/arkit/tracking-geographic-locations-in-ar?language=objc
But I'm in a location that ARGeoTrackingConfiguration.checkAvailabilityWithCompletionHandler: always return false. I think ARGeoAnchor isn't supported in my location.
I tried to use simulated locations by
Adding a gpx file when launching the app.
Enabling Xcode -> Debug -> Simulate Location -> New York, NY, US
But the availability for ARGeoAnchor is still false.
Is that possible for me to develop the ARGeoAnchor feature outside of the covered areas?
MapKit
RSS for tagDisplay map or satellite imagery from your app's interface, call out points of interest, and determine placemark information for map coordinates using MapKit.
Posts under MapKit tag
130 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
This is the complete Playground code:
import MapKit
import SwiftUI
import PlaygroundSupport
struct AddressSearchView: View {
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194),
span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)
)
var body: some View {
VStack {
Map(position: .constant(MapCameraPosition.region(region))) {
}
.frame(height: 300)
}
}
}
struct AddressSearchView_Previews: PreviewProvider {
static var previews: some View {
AddressSearchView()
}
}
PlaygroundPage.current.setLiveView(AddressSearchView())
When I try to run this I get this in the debug console:
error: Couldn't look up symbols:
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
protocol witness table for _MapKit_SwiftUI.EmptyMapContent : _MapKit_SwiftUI.MapContent in _MapKit_SwiftUI
Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler.
the preview never shows up. If I use other SwiftUI components and not the map it works fine. What is happening?
Playground target is Swift 6 macOS (iOS does the same).
Xcode 16.2
I'm implementing a Map with user location customization in SwiftUI using iOS 17+ MapKit APIs. When using the selection parameter with Map, the default blue dot user location becomes tappable but shows an empty annotation view. However, using UserAnnotation makes the location marker non-interactive.
My code structure:
import SwiftUI
import MapKit
struct UserAnnotationSample: View {
@State private var position: MapCameraPosition = .userLocation(fallback: .automatic)
@State private var selectedItem: MapSelection<MKMapItem>?
var body: some View {
Map(position: $position, selection: $selectedItem) {
// UserAnnotation()
}
.mapControls {
MapUserLocationButton()
}
}
}
Key questions:
How can I replace the empty annotation view with a custom avatar when tapping the user location?
Is there a way to make UserAnnotation interactive with selection?
Should I use tag modifier for custom annotations? What's the proper way to associate selections?
Hi everyone, i'im having troubles using Annotation on a Map View. I have a a core data model called Location that conforms to NSManagedObject from CoreData and MKAnnotation form MapKit, and i'm trying to add an array of Location to a MKMview instance in a UIViewController class, by doing somethhing like this: mapView.addAnnotation(locations), but xcode compliants with a strange error which says Argument type '[Location]' does not conform to expected type 'MKAnnotation'. it's strange to me because my Location class conforms to MKAnnotation protocol and i implemented the protocol's methods (coordinate, title, subtitle).
Please can anyone help me how to fix this issues. Thank you all
We are experiencing an issue where our app gets stuck during launch. The splash screen appears for some time, and then the app either becomes unresponsive or closes unexpectedly. However, there are no crash logs captured in Xcode or Firebase Crashlytics, indicating that the app is not crashing but rather being terminated. This issue is preventing affected users from properly launching the app.
Additionally, some users have reported occasional lag and slow performance when using the app. The issue occurs only for a specific subset of users and appears to be related to other Electronic Logging Device (ELD) apps running in the background. When these apps are active, our app struggles to launch and sometimes becomes unresponsive.
We suspect that this behavior could be related to system resource allocation, such as high memory consumption by background apps, which might be affecting our app's ability to launch correctly. However, we have been unable to reproduce the issue on our end despite multiple attempts.
Actions Performed During App Launch:
Firebase configuration
API requests, including:
Fetching account details
Registering the FCM token with the server
Asynchronous background requests to fetch POI details
Creating a local database and storing POI data in local storage
We would like guidance from Apple regarding potential causes and debugging strategies, especially in scenarios where the app does not produce crash logs but still fails to launch properly. Any insights into memory management, conflicts with background applications, or system resource constraints would be highly appreciated.
Steps to Reproduce:
Install and launch the app on an affected device.
Observe that the app gets stuck on the launch screen.
After some time, the app terminates unexpectedly.
Issue is inconsistent and occurs only for certain users.
Presence of other ELD apps running in the background appears to influence the issue.
I'm working on a proof of concept, and the goal I have is: To have an array of coordinates, and animate differently to each one.
Here is the following code I have:
.mapCameraKeyframeAnimator(trigger: startSequence) { camera in
KeyframeTrack(\MapCamera.centerCoordinate) {
for pin in viewModel.mapPins {
if pin == viewModel.mapPins.first {
CubicKeyframe(pin.coordinates, duration: 3)
} else {
CubicKeyframe(pin.coordinates, duration: 3)
}
}
}
KeyframeTrack(\MapCamera.heading) {
for pin in viewModel.mapPins {
if pin == viewModel.mapPins.first {
LinearKeyframe(camera.heading, duration: 1.5)
CubicKeyframe(camera.heading + 45, duration: 4)
} else {
LinearKeyframe(camera.heading, duration: 1.5)
CubicKeyframe(camera.heading + 45, duration: 4)
}
}
}
}
Now on the .heading keyframe, it throws the error: Underlying type for opaque result type 'some KeyframeTrackContent' could not be inferred from return expression. This only happens inside a for-loop and when there are multiple frames.
Figured it needs to return a KeyframeTrackContent object but it 1. doesn't have an initializer and 2. Using the builder static func throws an unknown error bug. If anyone is into mapkit and could help me out, much would be appreciated!
Edit: Please note that using Group, for-each, or any other type of view does not work as it needs to return KeyframeTrackContent
Has anyone gotten custom buttons to work on top of tvOS Map()? I've tried many variations of
FocusState
focusSection
.defaultFocus()
and as soon as the map appears at startup the buttons never get focus again. They are on a ZStack over the map. I could post code but truthfully nothing works for me. I'm wondering if anyone has successfully put focusable buttons on top of the map view.
Why is the pitch slider always visible in the SwiftUI tvOS map view? It doesn't even appear to be supported there, let alone the fact that I specify mapControlVisibility(.hidden). Am I missing something or is Apple? See attached screenshot. This really messes up my UI.
Here is my code:
import SwiftUI
import MapKit
struct ContentView: View {
@State var position = MapCameraPosition.region(MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194),
span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)))
var body: some View {
Map(position: $position)
.mapControlVisibility(.hidden)
.mapStyle(.standard(pointsOfInterest: .including(.airport)))
}
}
Hi all,
here's a tiny litte demo app
import SwiftUI
import MapKit
struct MarkerData: Identifiable {
var id = UUID()
var coordinate: CLLocationCoordinate2D
}
struct MapView2: View {
@State private var markers: [MarkerData] = []
var body: some View {
ForEach(markers) { marker in
Text("\(marker.coordinate)")
}
Map {
ForEach(markers) { marker in
MapMarker(coordinate: marker.coordinate)
}
}
}
}
The ForEach loop inside the Map gives the error:
"Generic parameter 'V' could not be inferred"
The one above seems to be fine.
What is wrong with the loop inside the map?
(I'm working with XCode Version 16.2)
Best!
https://developer.apple.com/documentation/mapkit/mkgeojsondecoder?changes=__9&language=objc
I am trying to use this decoder to obtain single points form a geojson file. I am able to do this successfully however, when using MapKit for iOS 17+ I am unable to use a ForEach to iterate through these points (stored in an array) and display these on the map as a custom annotation or even a marker.
MapAnnotation(coordinate: point.coordinate) {
VStack {
Image(systemName: "mappin.circle.fill")
.resizable()
.frame(width: 25, height: 25)
.foregroundColor(.purple)
if let title = point.title {
Text(title)
.font(.caption)
.foregroundColor(.purple)
.padding(2)
.background(Color.white.opacity(0.8))
.cornerRadius(3)
}
}
}
Hello,
Probably a noob question but I can't find any example code around this use case, and really no past questions I could find that address it either.
So, I really love that, when a user taps a POI on the map in my app, the map figures out the right POI every time. Flawless. However, when using .mapFeatureSelectionAccessory, I've tried probably 10-12 iterations, and there doesn't seem to be any way to either:
a) add custom content to the place card that's shown, or
b) replace that place card altogether with a view of my own, or
c) capture the place data but use it in a custom view
I want to be able to leverage the accuracy of Apple's tap gesture detection, but show, for example, only the name of the place, along with buttons and a form I have in a view.
Right now if I'm using .mapFeatureSelectionAccessory, I can't seem to bypass the place card at all.
I recently converted over my map from Mapbox Maps to MapKit Map. I have been able to add my polygons on the Map using MapPolygon. The issue I am having is being able to select the Polygon to be able to view information about the polygon.
Has anyone been able to figure out a way to tap on the Polygon? I have tried selection but the Polygon doesn't recognize the tap. I would really appreciate it if anyone could point me in the right direction of how I can accomplish this.
The easiest way to explain this is to show it. On any device, open Maps, set it to Driving (which will show traffic). Go to Baltimore Maryland. In the water just south east of the city there is a bridge (Francis Scott Key Bridge). . On Apple Maps the road is colored dark red.
At certain zoom levels, there is a "button" (red circle with a white - in it). When you click on that "button", it says 1 Advisory (Road Closed).
How do I show this "button" on my map. My map shows the dark red color, but no "button" appears.
The only "advisory" that I've been able to find is when you create a route. Of course you can't create a route over a road that fell into the water.
struct ContentView: View {
@State private var position = MapCameraPosition.region(
MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 39.22742855118304, longitude: -76.52228412310761),
span: MKCoordinateSpan(latitudeDelta: 0.05407607689684113, longitudeDelta: 0.04606660133347873)
)
)
var body: some View {
Map(position: $position)
.mapStyle(.standard(pointsOfInterest: .all, showsTraffic: true))
.cornerRadius(25)
}
}
Is this a WCDWAD, or is there a way to show the "button"
(We Can't Do What Apple Does)
Hi. I've been developing an app that uses Mapkit. Is Mapkit allowed in the Swift Student Challenge? If not, does anyone know of any offline alternatives to Mapkit or a way to make mapkit offline? I've been developing my app for way too long until I questioned whether its allowed.
Thanks,
Creeper25
In Apple's Maps app, an annotation is made up of a circle shape or rounded rectangles with a glyph-image.
When selecting an annotation, the annotation animates into a balloon marker (see attached GIF).
How does Apple Maps solve this - from custom annotation to balloon marker with spring animation?
I switched my Maps implementation from SwiftUI to UIKit with a UIViewRepresentable to support annotation clustering - and it works beautifully.
But how to subclass an MKAnnotationView (or MKMarkerAnnotationView <- the balloon) to enable selection and animation as in Apple Maps?
MKMarkerAnnotationView only show balloon markers and I tried everything inside MKAnnotationView (CALayer, etc.)
The code below using LookAroundPreview works fine on iOS (showing the preview image with a button saying "Look Around" at the top to enter full screen with navigation), but on macOS (15.3) there is no button and no way to navigate the view. Is this a bug or is there something I need to do differently on macOS? I have also tried using AppKit with MKLookAroundViewController and I don't seem get the button to launch full screen there either.
import SwiftUI
import MapKit
struct ContentView: View {
var body: some View {
LookAroundPreviewView(coordinate: CLLocationCoordinate2D(latitude: 37.33182, longitude: -122.03118))
.frame(width: 300, height: 200)
}
}
struct LookAroundPreviewView: View {
let coordinate: CLLocationCoordinate2D
@State private var scene: MKLookAroundScene?
@State private var errorMessage: String?
var body: some View {
Group {
if scene != nil {
LookAroundPreview(scene: $scene, allowsNavigation: true)
} else if let errorMessage = errorMessage {
Text("Error: \(errorMessage)")
.foregroundColor(.red)
} else {
ProgressView("Loading Look Around Preview...")
}
}
.task {
do {
let request = MKLookAroundSceneRequest(coordinate: coordinate)
let fetchedScene = try await request.scene
scene = fetchedScene
} catch {
errorMessage = error.localizedDescription
print("Error loading Look Around scene: \(error)")
}
}
}
}
I have a map where I am using UserAnnotation() to show the user's location.
Location permissions are handled elsewhere in the app.
If the user has previously granted location permission, that is enough for the UserAnnotation() blue pin to appear. Otherwise, it just doesn't draw.
So the Map already knows the user's permission and location without my code again requesting location etc.
I was looking for a way to leverage the map's knowledge of the user's location and came across this struct as described in the Documentation for SwiftUI Mapkit
public struct UserLocation {
public var heading: CLHeading?
public var location: CLLocation?
}
I thought this struct might expose the user's location, but how it is expected to be used or when it should populated is unknown from the point of the documentation.
Would someone please share the purpose and use of this struct?
Hello everyone,
I’m encountering a problem on the latest iOS 18 related to location permissions. When the user denies location access, my app triggers the standard system prompt asking them to enable location from Settings. On iOS 17 and below, tapping the “Settings” button in this system alert would successfully navigate the user to my app’s Settings page. However, on iOS 18, nothing happens. Instead, I see the following warning in the Xcode console:
Warning :
BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(:) needs to migrate
to the non-deprecated UIApplication.open(:options:completionHandler:).
Force returning false (NO).
Important details and context:
In my own code, I have already replaced all calls to openURL(:) with open(:options:completionHandler:).
I searched the entire codebase for usage of openURL: and didn’t find any.
The alert that appears is the system location alert (iOS-generated), not a custom UIAlertController. Thus, I have no direct control over the underlying call.
On iOS 17 (and below), tapping “Settings” in the same system dialog works perfectly and takes the user to the app’s permission page.
The console message implies that somewhere—likely inside the system’s own flow—the deprecated API is being called and blocked on iOS 18.
What I’ve tried:
Verified I am not calling openURL: anywhere in my code.
Confirmed that UIApplication.openSettingsURLString works when I programmatically open it in a custom alert.
Tested multiple times on iOS 17 and iOS 18 to confirm the behavior difference.
Steps to reproduce:
Install the app on a device running iOS 18 Beta.
Deny location permission when prompted.
Trigger a piece of code that relies on location (e.g., loading a map screen) so that the OS automatically shows its standard “Location is disabled” alert, which includes a “Settings” button.
Tap “Settings.” On iOS 17, this navigates to the app’s Settings. On iOS 18 Beta, it does nothing, and the console logs the BUG IN CLIENT OF UIKIT warning.
Questions:
Is this a known iOS 18 bug where the system’s own alert is still using the deprecated openURL: call?
If so, are there any workarounds besides presenting a custom alert that manually calls open(_:options:completionHandler:)?
Thank you in advance. Any guidance or confirmation would be appreciated!
My organization, Los Angeles Pierce College, rents space to "Topanga Vintage Market", which is a monthly weekend swap meet operation.
Apple Maps shows the location as roughly 34.18715° N, 118.58058° W. However, this is the location of the campus Child Development Center, which provides child care services and is not open during the hours of the Topanga Vintage Market.
The actual location should be in the adjacent large parking lot, roughly 34.18740° N, 118.57782° W. They do not have a physical building.
How do I get this resolved? I am putting a campus mapping application into the App Store real soon now.
There is also an entry for "ALC Taco Truck" about 34.18533° N, 118.57349° W, which as far as I know has not been on campus since Covid.
Thanks in advance for any guidance you can provide.
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
MapKit JS
MapKit
Maps and Location
Apple Maps Server API
We are developers of a golf app designed to assist golfers on the course. A key feature of our app is displaying a map of each hole, and we are currently transitioning to using MapKit and camera functionalities for this purpose. However, we are encountering issues with the downloading of map tiles when using the default satellite imagery.
We have tried several approaches to diagnose the issue:
We have tried several things to diagnose the issue:
We implemented the mapViewDidFailLoadingMap delegate method. But it is inconsistent, sometimes triggering offline errors even when map tiles are cached.
We implemented, the mapViewDidFinishRenderingMap method, but it always returns false when offline or you won't get the callback. Which doesn't let us know that rendering tiles has failed.
We would appreciate your guidance on the following specific questions:
Does MapKit provide a way to confirm if a map tile has fully loaded?
Is there a method to detect if a portion of the map hasn't loaded or if a tile request has failed?
Can we determine whether a map tile is cached, and if so, how long it will remain cached, similar to Cache-Control HTTP headers?
Is there a way to trigger the preloading of map tiles when we know the user has a good internet connection?
Please see the sample project for steps to reproduce the issue.
Thank you for any assistance!