Maps & Location

RSS for tag

Learn how to integrate MapKit and Core Location to unlock the power of location-based features in your app.

Maps & Location Documentation

Post

Replies

Boosts

Views

Activity

No pop up to ask a user’s location within the app in MacOS
I have a map tool app in MacOS which needs request Location permission to show MapUserLocationButton. During development, the request for permission can pop up for the first run in my mac, but when it comes to the Apple review(Submission ID: 11f52f82-1d54-481a-9eed-880521fda2b3), they never see that. My mac is Macbook air M2 2022, 14.5 (23F79). Of course, enable App Sandbox - Location and fill up the Privacy - Location When in Use Usage Description Code: // // LocationManager.swift // import MapKit @Observable class LocationManager: NSObject { static let shared = LocationManager() private let manager = CLLocationManager() var isReady: Bool = false var showingAlert = false // var location: CLLocationCoordinate2D? var isAuthorized: Bool { #if os(macOS) .authorized == manager.authorizationStatus #else .authorizedWhenInUse == manager.authorizationStatus #endif } private override init() { super.init() manager.delegate = self manager.desiredAccuracy = kCLLocationAccuracyBest setup() } private func setup() { isReady = isAuthorized #if os(macOS) if CLLocationManager.locationServicesEnabled() { checkStatus() } else { showingAlert = true } #else checkStatus() #endif } private func checkStatus() { switch manager.authorizationStatus { case .notDetermined: manager.startUpdatingLocation() #if os(macOS) #else manager.requestWhenInUseAuthorization() #endif #if os(macOS) case .restricted, .denied: showingAlert = true case .authorizedAlways, .authorizedWhenInUse: manager.startUpdatingLocation() #else // case .authorizedWhenInUse: // manager.requestLocation() #endif default: break } } } extension LocationManager: CLLocationManagerDelegate { func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { isReady = isAuthorized guard isReady else { return } // manager.requestLocation() } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { // location = locations.last?.coordinate } }
2
0
244
3w
Apple Maps cannot route to Latitude & Longitude
I've started getting reports of this today and I am able to replicate it on my end but looking to see if anyone else can verify or if it's possibly regional to me (Canada). In Apple Maps (iOS or macOS), if you search a latitude and longitude -- for example: "49.110,-112.110" and search, it centers on the location as it always has and shows the "Directions" button. When you tap the directions button, I get "A route can't be shown because of a problem connecting to the server.". Alternatively, if you pass the coordinate in via Apple Maps URL (https://maps.apple.com/?daddr=49.110,-112.110) it will route but the route is no longer to those specific coordinates, Apple Maps alters them to some nearest known entity (in this case, the RM of Warner County). If you compare the suggested route end destination with the search results for specifically entering the coordinates, you will see they are different locations and mapping routes are not actually taking you to the coordinates anymore. In the last photo attached, the arrow points to where "49.110,-112.110" is actually located which tapping the "Directions" button cannot figure out a route because of a server issue. If you pass it in via URL, it changes the destination coordinates and begins a route quite a ways away from the intended coordinate. The problem started happening either this morning or last night. Can anyone else confirm this happens to them? Thanks, Mike
7
3
680
May ’24
https://maps.developer.apple.com/ not accessible 403 forbidden.
Dear Community, After logging into my Developer Account, I am unable to access MapKit JS link under Additional resources. Each time I try to access https://maps.developer.apple.com/ or specifically https://maps.developer.apple.com/token-maker the browser returns 403 forbidden error. I have tried to use different browser an device and I get the same error. My MapKit JS Authorization token has expired and I need to reissue fresh token ASAP. Kindly advice. Regards, Swapneel Shah
1
1
282
May ’24
Apple map consultings price
Good afternoon, I'd like to get detailed information about the price usage of the Apple Map in my app in IOS (Swiftui for Iphone and Ipad). I'd like to establish a future price for the app subscription and to do that I need to obtain the precise prices for opening the map, consulting Map items, creating routes, the price of each consulting, and any other price that is related to the map usage process. I have been searching for this information and it has not been easy to find answers. I appreciate it if I could get the information. Best regards, Marcello Lima
2
0
373
May ’24
Unable to load MKMapView from AppKit bundle in Catalyst app
I am trying to load an auxiliary window from an AppKit bundle that loads a NSViewController from a storyboard. This NSViewController displays a MKMapView. I want to avoid supporting multiple windows from my Catalyst app so I do not want to load this window via a SceneDelegate, and that is why I have chosen to go the AppKit bundle route. If I load a similar view controller which contains a single label, then all works as expected. However, if I try to load a view controller with the MKMapView, I get the following error after crashing: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MKMapView nsli_piercingToken]: unrecognized selector sent to instance 0x15410f600' DropBox link to sample app with buttons on a view to select either the "Map View" (crashing) or the "Label View" (working): https://www.dropbox.com/scl/fi/q9daurhzqvil9o2ry6k1t/CatalystMap.zip?rlkey=yjbqfn6uxfrfh1jgsdavagta7&dl=0
2
0
346
May ’24
API Key for MapKit not working for Delphi/TMS
I have generated a key for MapKit and it gave me a private key (p8), a Key ID and a MapKit JS key. I am trying to use MapKit in Delphi TMS FNC Maps but it does not seem to render the maps. The same code works with Google Map Key, but not Apple MapKit. I was told to use the MapKit JS key in TMS by the vendor, but neither the Key ID or the MapKit JS key worked. Any help on this is greatly appreciated. Thank you
1
0
275
May ’24
Flickering after removing MapKit MapPolygons/Polylines
I'm using MapKit for SwiftUI and having an issue when conditionally rendering MapPolygons or MapPolylines. Removing these overlays after a previous render causes them to flicker sporadically in their previous location when a user zooms or moves the camera. The relevant code is as follows: Map(position: $cameraPosition, scope: mapScope) { MapPolygon(coordinates: selectedTileVertices) .stroke( Color(red: 1.0, green: 1.0, blue: 1.0, opacity: isTileSelected ? 1.0 : 0.0), style: StrokeStyle(lineWidth: 5, lineJoin: .round)) .foregroundStyle(selectedTile.color.opacity(0.0)) } A polygon is rendered around a coordinate that a user selects. Upon selecting a new coordinate, a new polygon should render and the old be completely removed from the map. In practice, the new polygon is rendered and the old initially removed, but upon zooming the old polygon flickers in and out of appearance. At some zoom levels the old polygon is completely visible again. The crux of the problem sees to be that I am using .mapStyle(.imagery(elevation: .realistic)). Upon switching to .hybrid all flickering behavior is gone. The flickering becomes worse when doing a lot of zooming/camera movement while the old polygon is rendered and then swapping to a new polygon, and is largely nonexistent if swapping to a new polygon at the same zoom level. I imagine this has something to do with the extra rendering optimizations for satellite imagery. Any help resolving this issue would be appreciated.
0
0
237
May ’24
Find Location Services in Sysdiagnose?
Hi guys! I am trying to extract Location Services data from an iPhone running developer mode, and have installed the "Location Services for iOS" Profile that can be found on the Profiles and Logs page. I have also read the Instructions PDF, and done the setup. I am having a hard time finding the actual logs after exporting the sysdiagnose folder. The folder is quite big and complex. Can someone please help me, and tell me where I can find it? Thanks!
1
1
360
Feb ’24
Inquiry About Using Find My Network for Third-Party App Development
Hello everyone, I hope you’re all doing well. I have a question regarding the use of Apple's Find My network. I’m in the early stages of developing an app that would track third-party Find My-compatible tags. Before proceeding further, I want to ensure that I am compliant with Apple’s guidelines and policies. Can anyone provide insight into whether Apple allows developers to use the Find My crowd-sourced network for their own apps? Specifically, I'm interested in tracking third-party Find My tags through my app. Any guidance or resources you can share would be greatly appreciated! Thank you!
1
0
312
May ’24
Questions about Live Activities
Our app is a time reporting service with various functions around that. The user checks in at work, checks out when they go home. We thought it'd be useful to provide a live activity to show how long they have worked for. There is also a couple of other cool things we could do that users would love, but i couldn't find definitive answers to the questions below. 1. We have a geofence-based function that checks the user in when they for example arrive at work, and check them out when they go home, so that they don't have to open the app. However, this means that we will need to start and end the live activity from within a geofence trigger. Is this possible? 2. It seems that the maximum time for a live activity is 8 hours? Sometimes people work for longer... How would we solve this? i would be fine with 12 since it would solve most cases. Is it possible somehow to go beyond 8 hours up to 12? If not, is there a callback that "8 hours are up!" so that i could do a final update on the live activity from a counter to "you started working at 09:04" 3. I have seen that some live activities have buttons. It would be neat if the user can check out via a button on the live activity. However, since we take location and call our servers when checking out, we need to be able to use both the locationmanager and make a network call from the live activity. Is this possible? Thanks in advance, Cheers
0
0
304
May ’24
ReverseGeocode works badly (returns nonsense)
Users of my app are complaining about incorrect GPS location decoding. I found that the bug is in the reverseGeocode, because it returns nonsensical results. Example: The user is located in Oberhausen, Deutschland at coordinates 51.482015, 6.887064. ReverseGeocode decodes the coordinates as "Oberhausen bei Kirn". It is mistaken 250 km! ReverseGeocode works like this: 51.48, 6.88 - Oberhausen (OK) 51.482, 6.887 - Oberhausen bei Kirn (Error) 51.48, 6.89 - Oberhausen (OK) Test result: If the coordinate precision is greater than 2 decimal places, the reverseGeocode does not work properly. From what the user told me, more apps behave like this. Probably all that work with precise coordinates.
1
0
298
May ’24
SwiftUI iOS 17, Xcode 15.3 MapContentBuilder
I consistently get an error that the Map initailizer I'm using is deprecated and I should use a MapContent builder instead. Various errors such as "'MapAnnotation' was deprecated in iOS 17.0: Use Annotation along with Map initializers that take a MapContentBuilder instead." or "'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:annotationItems:annotationContent:)' was deprecated in iOS 17.0: Use Map initializers that take a MapContentBuilder instead." The problem in my code seems to be located here: import SwiftUI import MapKit struct ContentView: View { @State private var region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 34.0522, longitude: -118.2437), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5) ) @State private var restaurants: [Restaurant] = [] var body: some View { Map(coordinateRegion: $region, annotationItems: restaurants) { restaurant in // This uses the updated Annotation API MapAnnotation(coordinate: restaurant.coordinate) { VStack { Text(restaurant.restaurantName) .bold() .foregroundColor(.white) .padding(5) .background(Color.black.opacity(0.75)) .cornerRadius(10) .fixedSize() Image(systemName: "mappin.circle.fill") .foregroundColor(.red) .font(.title) } } The errors persistently occur in the lines immediately below var body: some View { I've been stuck on this for two days now. Any help would be greatly appreciated.
1
1
361
May ’24
2024: Beacon based iOS app not working since iOS17 update
My app is using iBeacons, and I am using func startMonitoring(for region: CLRegion). Then I am using func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) and func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) to run logic when user enters / exits certain Beacon CLBeaconRegion. Everything worked fine until recently, iOS 17 update I guess. Now after I call startMonitoring(for: region) the code works for couple hours, and then it seems my app is somehow suspended and no longer able to use CoreLocation, and my code does not work, entry and exit events to beacon regions are NOT detected. Funny enough I have some Beacon managment apps that can scan for nearby beacons, when I run one of those apps, I see on top of iPhone screen “hollow arrow” sign that marks CoreLocation being used, and then my app works for few minutes, and then again my app is suspended, and no entry/exit events into beacon regions are detected. I could figure out how to engage CoreLocation but that would rely on user intentionally opening my app, and the sole purpose of my app is to remind user when he is near one of his Beacons, so expecting user to remember to open my app defeats my apps purpose. I added Location Updates under Background Modes for my app , maybe my app has little bit more background time until it is suspended, but the problem still persists. So for any Beacon based app to work it should be able to monitor for nearby beacons, and run logic once beacons are detected. Any suggestions on how I could solve this? iOS 17 CLMonitor has BeaconIdentityCondition that can match UUID, major, minor but this is only to detect we are NEAR a Beacon (entry event), what about exit event? Should I monitor for a change in Condition from .satisfied to .unsatisfied and that transition is Exit event? My questions: Is there a way to use old code: startMonitoring(for: region) - how to fix my app so it DOES NOT get suspended, and so that this method can monitor for beacons in background with AlwaysAllow authorization? If not and I must switch to CLMonitor how do I capture Exit event - when user exits Beacon region in iOS 17 using CLMonitor? Thanks
0
0
262
May ’24
iBeacon Notification Delayed Many Hours
We have an app that has been using iBeacons and Geofences for 10+ years. While I cannot state when it started, we're seeing sporadic delays of hours to receive iBeacon "didExitRegion" event. I can prove this out on my iPhone running iOS 17.4.1 by setting up both a Geofence and an iBeacon in the same physical location. Yesterday, I have a several hour gap with no iBeacon events, but successfully see Geofence events. Then, an hour+ after leaving the Geofence, I get multiple didExitRegions from the same iBeacon (all without touching the app). Then this morning, everything again is working great. It "feels" like the phone stops delivering entry and exit events for the Bluetooth iBeacon for some period of time. Then, it resumes monitoring by first providing old event that were not delivered to us in real time. It's not atypical for me to see a didExitRegions event that should happen around 5pm that instead happens in the middle of the night. So far, I have not noticed this behavior for our app running on iOS 16.4.1. We're currently testing other versions of iOS to see if we can pinpoint when it started. I have a full battery so we've ruled out power saving mode. Bluetooth is on with all permissions of course. We are still receiving Geofence updates so we must have available background time. Is there any known issue in iOS 17+ that would explain this behavior? Or, is there any Feedback/Radar to explain it? Known issue?
1
1
290
May ’24
Update to Xcode 15.3 has MapKit performance threading issues.
Seeing the following, whether initializing Maps() in SwiftUI or using Apple's example Overlay Project since updating to Xcode 15.3: Thread Performance Checker: Thread running at User-interactive quality-of-service class waiting on a thread without a QoS class specified (base priority 0). Investigate ways to avoid priority inversions PID: 2148, TID: 42369 Backtrace ================================================================= 3 VectorKit 0x00007ff81658b145 ___ZN3geo9TaskQueue5applyEmNSt3__18functionIFvmEEE_block_invoke + 38 4 libdispatch.dylib 0x00000001036465c2 _dispatch_client_callout2 + 8 5 libdispatch.dylib 0x000000010365d79b _dispatch_apply_invoke3 + 527 6 libdispatch.dylib 0x000000010364658f _dispatch_client_callout + 8 7 libdispatch.dylib 0x0000000103647c6d _dispatch_once_callout + 66 8 libdispatch.dylib 0x000000010365c89b _dispatch_apply_redirect_invoke + 214 9 libdispatch.dylib 0x000000010364658f _dispatch_client_callout + 8 10 libdispatch.dylib 0x000000010365a67f _dispatch_root_queue_drain + 1047 11 libdispatch.dylib 0x000000010365af9d _dispatch_worker_thread2 + 277 12 libsystem_pthread.dylib 0x00000001036e2b43 _pthread_wqthread + 262 13 libsystem_pthread.dylib 0x00000001036e1acf start_wqthread + 15```
0
1
331
May ’24
Spatial music-based navigation.
Hey, I've developed a new audio-based navigation technology for my Master's project at Imperial College London. The main aim of it is to take away the need for an annoying voice based prompt to interrupt your music ("Turn left in 300 yards"). Instead I've created a more natural interaction where the listener's music is binaurally spatialised to provide less annoying directional information. I've tested the product with many users and the feedback has been really positive! I just wondered whether anyone knew someone at Apple that I could have a chat with about this technology? I think it would work great if it was linked to Apple Maps, especially now with the integration of head-tracking into the Airpod Pro's.
0
0
208
May ’24
CLMonitor Add region after starting to monitor for event changes
I am currently working on an app that uses the CLMonitor to check when the user has entered a specific region. When the user enters the region, a new region should be monitored, and the old region should be removed. Currently, I have a startMonitoring() method that contains the event handling logic: func startMonitoringConditions() { Task { monitor = await CLMonitor(MonitorNames.monitorName) if let identifiers = await monitor?.identifiers { if identifiers.count == 0 { if let coordinate = manager.location?.coordinate { await addNewRegionAtCoordinate(coordinate: coordinate) } } else { print("Previous Monitor Region is used.") } } for try await event in await monitor!.events { if let coordinate = manager.location?.coordinate { // do something... await monitor!.remove(event.identifier) await addNewRegionAtCoordinate(coordinate: coordinate) } } } } Unfortunately, adding a new region will not update the events collection in the CLMonitor, so the new region's events will not be handled in this method. Any help on how I could fix this problem would be greatly appreciated!
5
1
700
Nov ’23
MapKit warnings and map Errors -Mismatching number of indices
Hi there, I am trying to develop a country guessing game using MapKit and GeoJSON data. I have verified that my data creates the outline of the country properly using other methods, but I run into an error where the map clips and does not show portions of the countries or islands when zooming at certain levels of the map. I receive the warnings in the terminal "Mismatching number of indices, indexCount: 30, triangulatedIndexCount: 27" and "Triangulator failed to fully triangulate polygon: (0.1296, 0.303328), (0.108053, 0.296605), (0.0671644, 0.289883), (0.0586311, 0.281121), (0.0397156, 0.27289), (0.0323911, 0.262393), (0.0610489, 0.260732), (0.102507, 0.284671), (0.140053, 0.292602), (0.133511, 0.291167), (0.137707, 0.293659), (0.138489, 0.29872)" I am not sure what these tuple values are, or how to fix the errors, as I have adjusted my data (removing duplicate coordinates, refreshing the map, etc). How am I able to counteract these warnings, or at least get a sense of what they are asking?
0
0
259
Apr ’24