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

"hotels" query brings me to an hotel in Ramallah
When trying the request "hotels" on MapKitJS with searchRegionPriority=default, it will return an hotel in Ramallah even if the searchRegion is very far from there. It can happen if your search region is very broad in most place (above Europe if you zoom out a lot, over Turkey and Middle East even if the bounding box is narrower), but on specific places it happens even with a small search region (like in Tripoli, Lebanon, whatever the zoom level). With searchRegionPriority=required, many hotels can be found in the same area. Reproduce with: https://maps-api.apple.com/v1/search?q=hotels&searchRegion=34.45512816097114,35.849070061159864,34.428418939926146,35.80795182731595&lang=en&searchRegionPriority=default
0
0
20
1h
Horizontal and Vertical Accuracy for CoreLocation
We’re implementing a feature in our app that allows a certified MFi GPS device to act as the default location source for user positioning, replacing the internal GPS when connected. However, we’re noticing a significant discrepancy between the accuracy values reported by iOS and those directly available from the GPS device. Here’s the issue: When the MFi GPS is in use, it transmits standard NMEA messages (GGA, GSA, RMC, etc.) to the iOS device (providing HDOP and VDOP). However, the accuracy reported by iOS for this “location-system” seems to be less precise than what the GPS device itself reports. For example, here are the readings we observe: Location from iOS device (systemLocation): Position: <+41.4, +1.8> +/- 5.00m (speed 0.05 m/s / course 329.40) Timestamp: 6/11/24, 12:01:50 Central European Standard Time Horizontal Accuracy (from systemLocation): 5.0 meters (16 ft) Vertical Accuracy (from systemLocation): 9.5 meters (31 ft) Location from GPS device directly: Horizontal Accuracy: 9.1 ft Vertical Accuracy: 10.3 ft It’s evident that the accuracy values displayed by iOS differ from the values available from the GPS device, especially in terms of horizontal and vertical accuracy. Question: Is there a known reason for this discrepancy in accuracy values? Is there a way to obtain the GPS device’s native accuracy values in iOS, or is iOS applying additional filtering or adjustments that might explain this difference? If additional filtering is applied can be disabled? Any insights would be greatly appreciated, as accurate location reporting is critical for our app’s functionality.
1
0
53
1d
Carplay GPS issues
I have a 2010 F-150 with an Alpine iLX-F509 receiver using CarPlay. Intermittently, and currently, the GPS shows me traveling in the opposite direction that I'm heading which makes the directions completely useless. Happens regardless of wired or wireless connection. Once I unplug from the USB or disconnect from Bluetooth, the map and directions in my iPhone 13 work normally. When plugging back in, even if I've removed the car from CarPlay and reinstall it, the problem comes back. This seems to be a problem with communication between my phone and my truck GPS. Is this a software problem with CarPlay or with the Alpine system? The firmware on the Alpine is current. Could this possibly be a problem with compatibility or my GPS antenna? I do not seem to be having the same issue with my wife's 2020 CR-V. All other features of CarPlay seem to be working fine. It's just the map and the GPS. Doesn't matter which map I use either (Apple, Google).
2
0
57
2d
CLBackgroundActivitySession Crash Issue - Misleading Apple Guidance
I encountered a crash in iOS 17 related to CLBackgroundActivitySession, which appears to be due to misleading guidance in an Apple’s WWDC video. Crash sample code: https://github.com/steve-ham/AppleLocationCrash Simplified Reproduction Steps: 1. Open the GitHub sample app. 2. Archive and export (Distribute App -> Custom -> (Release Testing, Enterprise, or Debugging) -> Export). 3. Open the app. 4. Tap enableBackgroundLocation -> select Allow While Using App on the system popup. 5. Tap disableBackgroundLocation. 6. Go to the iOS home screen. 7. Wait for 10 seconds. 8. Reopen the app -> crash occurs. The crash happens because setting CLBackgroundActivitySession to nil does not end the session, despite Apple’s guidance suggesting it should. Below is the exact quote from WWDC 2023, which explicitly states that both calling invalidate() or letting the object get destroyed (i.e., setting to nil) would end the session: WWDC 2023 Discover Streamlined Location Updates (https://developer.apple.com/videos/play/wwdc2023/10180/) “Before starting the updates, you should instantiate a CLBackgroundActivitySession object to start a new session. Note, we are assigning the session to self.backgroundActivity, which is a property and not to a local variable. And this is important because if we used a local variable, then when it goes out of scope, the object it holds would be deallocated, invalidating the session and potentially ending your app’s access to location. Then when we want to end our session, we can do that by sending the invalidate message or by letting the object be destroyed.” I’ve submitted this to Apple for resolution but wanted to share this with the community. This misguidance has caused issues in my app’s release. If Apple could reply to confirm or provide clarification, it would be greatly appreciated. P.S. Even a minimal implementation in viewDidLoad triggers the crash: let session = CLBackgroundActivitySession() print("session (session)")
2
0
124
2d
Details on CLBackgroundActivitySession and CLServiceSession Diagnostic enum
I am working with the CLBackgroundActivitySession and CLServiceSession to figure out why our app is sometimes terminated in the background. I am unable to understand what "insufficientlyInUse" corresponds to, it could be understood as The location data is not being used enough the "While in use" permission is not enough It will be very helpful if the entire enum can be explained, I am attaching the one for CLServiceSession since it is a superset of CLBackgroundActivitySession from CoreLocation extension CLServiceSession { public struct Diagnostic { public var authorizationDenied: Bool { get } public var authorizationDeniedGlobally: Bool { get } public var authorizationRestricted: Bool { get } public var insufficientlyInUse: Bool { get } public var fullAccuracyDenied: Bool { get } public var alwaysAuthorizationDenied: Bool { get } public var serviceSessionRequired: Bool { get } public var authorizationRequestInProgress: Bool { get } } ... } Looking forward to hearing from you
2
0
91
2d
CLLocation liveUpdate Not Working After App Resurrects in Background
According to WWDC sessions, the recommended approach for continuing location collection in the background with liveUpdate is by using CLBackgroundActivitySession. In the app I’m currently developing, I call the invalidate function on the backgroundActivitySession instance when the app enters a terminated state. Then, when the app is resurrected due to startMonitoringSignificantLocationChanges, it reinitializes liveUpdate to resume location collection. When initializing CLBackgroundActivitySession, I also reinitialize the liveUpdates object to ensure the CLLocation.Updates instance is refreshed. However, regardless of the order in which I refresh these two instances, location collection does not resume when the app is revived in the background. Should the originally created CLBackgroundActivitySession instance never be invalidated? Any guidance on whether I am implementing this correctly would be greatly appreciated.
1
0
109
1w
IMDF Labels for Indoor Survey App
I have seen examples of conducting an Indoor Survey of an IMDF where it has labels on the map. This would help. Our structure is basically a huge hall that gets reconfigured weekly from a horse venue to a car show to a home and garden show. I was thinking of creating a series of walkways to criss cross the floor and then survey them once done. It would be nice to have a label of the features on the map. How is this done? Thank you, Mele
0
0
74
2w
can not find placemark when search by japanese character
when I using MKLocalSearch by japanese character let request = MKLocalSearch.Request() request.naturalLanguageQuery = "東京涩谷地下鉄駅" request.region = mapView.region let search = MKLocalSearch(request: request) search.start {....} ,it can not return the placemark, shows Error : The operation couldn’t be completed. (MKErrorDomain error 4.). Failed to parse font key token: hiraginosans-w6 how can I fix this problem,thankyou! import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var resultsTableView: UITableView! var mapView: MKMapView! var searchResults = [MKMapItem]() override func viewDidLoad() { super.viewDidLoad() mapView = MKMapView(frame: CGRect(x: 0, y: 220, width: view.bounds.width, height: view.bounds.height - (tabBarController?.tabBar.frame.size.height ?? 0))) mapView.showsScale = true mapView.showsCompass = true mapView.showsScale = true mapView.showsUserLocation = true mapView.userTrackingMode = .follow mapView.delegate = self view.addSubview(mapView) let selectedCoordinate = CLLocationCoordinate2D(latitude: 35.661777, longitude: 139.704051) // some Coordinate near 東京涩谷地下鉄駅 let selectedLocation = CLLocation(latitude: selectedCoordinate.latitude, longitude: selectedCoordinate.longitude) let coordinateMKCoordinateRegion = MKCoordinateRegion(center: selectedLocation.coordinate, latitudinalMeters: 50000, longitudinalMeters:50000) mapView.setCenter( selectedLocation.coordinate, animated: true) mapView.setRegion(coordinateMKCoordinateRegion, animated: true) drawCircle(radius: 5000, center: selectedLocation.coordinate) searchForStation() } func drawCircle(radius: CLLocationDistance, center: CLLocationCoordinate2D) { let circle = MKCircle(center: center, radius: radius) mapView.addOverlay(circle) } func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { if let circleOverlay = overlay as? MKCircle { let circleRenderer = MKCircleRenderer(circle: circleOverlay) circleRenderer.fillColor = nil circleRenderer.strokeColor = UIColor.blue circleRenderer.lineWidth = 2.0 return circleRenderer } return MKOverlayRenderer(overlay: overlay) } func searchForStation() { print( "searchForStation" ) let request = MKLocalSearch.Request() request.naturalLanguageQuery = "東京涩谷地下鉄駅" // request.region = mapView.region let search = MKLocalSearch(request: request) search.start { [weak self] (response, error) in guard let self = self else { return } guard let response = response, let mapItem = response.mapItems.first else { print("Error : \(error?.localizedDescription ?? "Unknown error").") return } for mapItem in response.mapItems { print( "mapItem.placemark =",mapItem.placemark) // hope to get 東京涩谷地下鉄駅placemark,the value of latitudeand longitude) } } } }
2
0
135
2w
Apple maps trail / local path only becomes visible on very close zoom
I'm using apple maps to build a feature so users can create and save running/cycling/hiking routes. Currently the map only shows trails and similar local paths after zooming in to what is basically an extreme level. I want the trails and local paths to be more visible on a further, broader level of zoom. APPLE MAPS JS EX: https://trkbucket.s3.amazonaws.com/media/shoe_images/Screenshot_2024-10-23_at_10.52.17AM.png https://trkbucket.s3.amazonaws.com/media/shoe_images/Screenshot_2024-10-23_at_10.52.04AM.png APPLE MAPS iOS EX: https://trkbucket.s3.amazonaws.com/media/shoe_images/IMG_9DDF5C9A320D-1.jpeg Also strange that on iOS the path is visible while more zoomed out whereas JS does not. Please advise how to show these map items at a broader zoom.
1
0
143
2w
Issue with geolocation without using maps
I have an application that uses geolocation to track the user’s location and trigger actions when the app is in either the foreground or background. Currently, it seems that region entry is not triggered unless an app like Maps (which actively uses location services) is opened. The location permissions are correctly set to “Always” with precise location enabled. We are using geofencing to setup region and trigger actions when entering or leaving. Is there something I’m missing in the configuration that could be preventing region monitoring from triggering properly when the app is in use or in background?
2
0
112
2w
how to show subway exit in the mapkit mapview
mapView.showsTraffic=true mapView.showsScale=true mapView.showsCompass=true mapView.showsUserLocation=true mapView.showsBuildings=true mapView.showsLargeContentViewer=true hi,guy,please help to see this problem,thankyou,the mapkit api support some showsfunction,but I can not find how to show the exit of subway in my own app,but the map app of appple shows the exit of the subway,so how can I show the exit of the subway stations by using mapkit
1
0
116
2w
Location "While in use" + Background?
I need some clarification on what is supposed to happen if the "allowsBackgroundLocationUpdates" flag on CLLocationManager is set to true, and only the "While in Use" permission has been given. The customer I'm working with thinks that this combination should allow the app to receive location updates in the background indefinitely, as long as the app was in the foreground when we started receiving them. What we've experienced is inconsistent. App updates do continue when the screen locks and in some cases when we switch to another app, but often they do not. Our app doesn't require location updates 24/7, it requires them for a period of time when the user is performing an activity. The user starts and stops the activity in the app, and the activity might last up to a couple of hours. Can we do this using "While in Use" or do we need to request "Always" ?
1
0
116
2w
Intermittent MKLocalSearch.Request Failures with Amap Data Source
My app has been using MKLocalSearch.Request for keyword-based location searches, and it has worked smoothly for a long time. However, starting last Wednesday, I began receiving an error from MKLocalSearch.start: MKErrorDomain (error code 4). This issue only occurs when the network environment is based in mainland China (where the API uses the Amap data source). When the network switches to other regions and other Apple Maps data source is used, the error does not occur. Another complication is that the API doesn't always fail—certain keywords still work (for example, "Huawei"). Already filed a ticket in Feedback Assistant: https://feedbackassistant.apple.com/feedback/15544549
1
0
116
2w
Apple Maps Server API Unauthorized Error
I'm trying to use the new Apple Maps Server API. As far as I can tell I have set up the token correctly, but my web request is still returning 401 unauthorized. The following is my code in TypeScript: import * as jwt from 'jsonwebtoken'; const JWT_SECRET = "-----BEGIN PRIVATE KEY-----\n" + "MIGTAgEAMBMGBy..............................\n" + "..............................................................\n" + "..............................................................\n" + "-----END PRIVATE KEY-----"; const header = { alg: "ES256", kid: "26DYPK65ZK", typ: "jwt" } // Example payload data const payload = { "iss": "7F3PBYWYMS", "iat": Date.now(), "exp": Date.now() + (1000 * 30 * 60), }; export async function getRestaurants() { let token = jwt.sign(payload, JWT_SECRET, { algorithm: 'ES256', header: header}); const response = await fetch('https://maps-api.apple.com/v1/token (https://maps-api.apple.com/v1/token)', { method: 'GET', headers: { 'Authorization': "Bearer " + token }, }); console.log(response); } What am I doing incorrectly here?
5
0
130
2w
CLMonitor does not always trigger on entry
I have an App which needs to monitor one CircularGeographicCondition for a feature. No other location services are required in the moment. Im facing the problem that entry events aren't forwarded to my implementation in every case on real devices. In the simulator everything is working like a charm. Exit events seemed to be working quite reliable on real devices too. Even after resuming the app from background in case of a missed entry event does not trigger the entry event. Only restarting (which recreates the monitor) triggers an entry event. The radius of my geofence is 200 meters What I have done: a. Holding a service session session = CLServiceSession(authorization: .always) b. Creating a Task which holds the CLMonitor, adds the conditions and loops through the events. My questions are: Is this expected behavior? If yes, how can I force the CLMonitor to recalculate the state of the condition? Thank you so much for your help
2
2
187
2w
can I specify the transit mode
aoubut MKLaunchOptionsDirectionsModeKey, when I use MKLaunchOptionsDirectionsModeTransit as a mode in my code to call function openMaps ,the apple map app launches,it has 4 mode ,subbay or ferry,bus etc,so how can I specify the subway to transit before apple map app launch,so that I do not need to select on the map app,just specific subway in my own app, then the map app auto select the subway transit navigation。now it shows two much usless route。
0
0
150
2w
bicycle mode to navigate
MKLaunchOptionsDirectionsModeDefault MKLaunchOptionsDirectionsModeDriving MKLaunchOptionsDirectionsModeWalking MKLaunchOptionsDirectionsModeTransit when I am using the mapkit navigation, I only see the 4 modes, but can not find the mode of bicycle, so how can I find the enum of using bicycle to navigate by bicycle ,than you!~ Xcode version is 16.
0
0
118
2w