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

MKMapview overlay renderding performance issue on iOS16
Hi , I have following scenario where I feel performance issue. Use-case: I have multiple Overlays(MKOverlay) rendered on MapView, and overlay needs to refresh on point Drag(MKPinAnnotation). I have custom logic to handle drag behaviour of annotation, on annotation drag I do update the overlay. As point update, I create new overlay with updated coordinate and re-render it. iT slow down the performance after few overlay added. Additional Notes: Performance was quite good on iOS16 but on iOS17, it lags the perforce on point drag. When I say it the performance, it point drag lags so it slow the overlay rendering. I am using MKMapView inside SwiftUI. I am sharing code-snippet where it re-render the overlay. Please help with issue in my code implementation. func renderSegments(mapView: MKMapView, segmentPoint: FencePointAnnotation, renderNeeded: Bool = true) { mapViewModel.updateFencePointOrder() guard let activeLayer = mapViewModel.activeLayer else { debugPrint("Invalid active layer.") return } let segments = mapViewModel.activeFence.connectedSegmentsOf(vertex: segmentPoint) // Remove existing overlay. for overlay in mapView.overlays { if let overlay = overlay as? FenceOverlay { if overlay.layerId == activeLayer.layerId { mapView.removeOverlay(overlay) } } else if let overlay = overlay as? FenceSegmentPolyline { if overlay.layerId == activeLayer.layerId { for segment in segments.values where segment.identifier == overlay.identifier { mapView.removeOverlay(overlay) } } } } // When vertex removed the no need to add segment if renderNeeded { if let segments = mapViewModel.updatedSegements(segment: segments.map({$0.key})) { let updatedSegments = mapView.updatedSegmentsWithOffset(segments: segments, layer: activeLayer) mapView.addOverlays(updatedSegments) } } }
2
1
86
6d
Siri can directly launch Map App for navigation
DESCRIPTION OF PROBLEM We discovered that Siri can directly launch Amap and Tencent Maps for navigation. Our app also wants to integrate this feature. After our research, we found that AppIntents cannot accomplish this functionality. Because the parameters of AppIntents are limited. How can we achieve this? Do we need to apply for certain permissions from Apple? STEPS TO REPRODUCE awake siri say "使用高德地图打车去南京南站"
1
0
22
1d
Find My shows gibberish for city/region etc. in eastern europe
When viewing relatives' in Find My back in Europe (Slovenia, Croatia, Serbia) their location shows as some nonsense like " , 18" rather than the town, region, or country they're in. This used to work, but stopped a couple of years ago. I've opened a couple of Feedback tickets over the last couple of years, but they've seen zero activity and after numerous iOS and macOS updates, there's been no improvement in the behavior, so it's been recommended to me that I point out the question here. Here are the links: https://feedbackassistant.apple.com/feedback/12159041 https://feedbackassistant.apple.com/feedback/13500852 Is anyone else seeing this sort of behavior?
2
1
115
4d
mapItemDetailSheet Not Displaying Information
I'm on MacOS 15 Beta and Xcode 16 Beta. Running iOS 18 Beta on a 15 Pro Max. I'm leveraging the .mapItemDetailSheet(item: input) option to pull up a sheet that displays the Place Card for a selection made from a List of places. This is working great on my iPhone 15 Pro Max and my iPad Pro 13. I also have the Mac Catalyst option added under: Project \ General \ Supported Destinations If I launch the app from Xcode via the play button, the app functions fine on my MacBook Pro and I get logs in Xcode, etc. However, if stop the session in Xcode and attempt to run the same app on its own on my MacBook Pro, the mapItemDetailSheet does not populate with any information. Anyone have ideas on where the disconnect could be? Why would the sheet populate with data when ran from Xcode but not when ran on its own? Again, it runs fine on the iPhone and iPad. Any ideas would be helpful and appreciated.
1
0
177
3w
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.
1
0
284
May ’24
Crash when CLLocationUpdate.liveUpdates is called while requesting authorization by CLServiceSession
I watched this video and programmed with this sample code as a reference. The application crashed when I toggled the switch with the following code. // // ContentView.swift // LiveUpdatesInCoreLocation // import os import SwiftUI import CoreLocation @MainActor final class ContentViewModel: ObservableObject { private let logger = Logger() @Published var updatesStarted: Bool = false { didSet { updatesStarted ? self.startLocationUpdates() : self.stopLocationUpdates() } } func startLocationUpdates() { Task { let _ = CLServiceSession(authorization: .whenInUse) for try await update in CLLocationUpdate.liveUpdates() { guard self.updatesStarted else { break } logger.debug("update location: \(update.location)") } } } func stopLocationUpdates() {} } struct ContentView: View { @StateObject private var model = ContentViewModel() var body: some View { VStack { Toggle("Location Updates", isOn: $model.updatesStarted) } .padding() } } And this is the error that occurred. Thread 8: EXC_BAD_ACCESS (code=1, address=0x10) A bad access to memory terminated the process. If you remove the below code, the error will not occur. let _ = CLServiceSession(authorization: .whenInUse) Therefore, I guess that the problem is in calling CLLocationUpdate.liveUpdates while CLServiceSession is requesting authorization. or am I doing something wrong?
1
0
45
2d
Location in the Background constant popups
We have a pair of apps that are used to monitor the location of a person and allow them to reach out for help when needed. The apps are designed to be used with persons with special needs. A large portion of our target audience is people that have cognitive disabilities. One app is used by people that monitor and help the person with needs, and the other is used by the person with needs who is not with them all the time. The issue we have is that our users have trouble understanding what to do when this verification popup appears. This popup continues to appear over and over and over. This is a severe health and safety issue for us. We find that the user is often times confused by the popup and is disabling the background location tracking preventing the needs provider from being able to track the location of the user. It would be great if there was a special Entitlement that could be granted that would prevent this 'feature' of iOS. Or possibly simply a setting that the user's provider can setup on their phone to stop the annoying and dangerous constant popups. If anybody knows of a way to prevent this popup, please let us know. Otherwise, if someone at Apple could suggest how we can make this happen in the future.
3
0
119
5d
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
9
3
858
May ’24
pointOfInterestCategory missing on mapkit js placeLookup
const lookup = new mapkit.PlaceLookup() lookup.getPlace(input?.id, (error, place) => { console.log("place", place) ... gives me for example { "id": "I65A54A72CE9E45D6", "alternateIds": [ "IB86C41DA005E0D9B" ], "muid": "7324342225941186006", "_styleAttributes": "4:226,6:16,10:0,82:12,85:12,89:1,164:1,193:1", "name": "The Museum of Modern Art", "region": { "center": { "latitude": 40.7612829, "longitude": -73.9768677 }, "span": { "latitudeDelta": 0.008983199999995861, "longitudeDelta": 0.01186000000001286 } }, "coordinate": { "latitude": 40.7617238, "longitude": -73.9777654 }, "formattedAddress": "11 W 53rd St, New York, NY 10019, United States", "countryCode": "US", "telephone": "+12127089400", "urls": [ "http://www.moma.org" ], "country": "United States", "administrativeArea": "New York", "administrativeAreaCode": "NY", "locality": "New York", "postCode": "10019", "subLocality": "Manhattan", "thoroughfare": "W 53rd St", "subThoroughfare": "11", "fullThoroughfare": "11 W 53rd St", "areasOfInterest": [ "Manhattan" ], "dependentLocalities": [ "Midtown Center", "Midtown East", "Midtown Manhattan", "Midtown", "North Hudson" ], "timezone": "America/New_York", "timezoneSecondsFromGmt": -14400 } Note there is no pointOfInterestCategory. but const place_search = new mapkit.Search() place_search.search( input, (error, result) => { console.log("result_places_0", result?.places?.[0]) ... i get { "id": "I65A54A72CE9E45D6", "alternateIds": [ "IB86C41DA005E0D9B" ], "muid": "7324342225941186006", "_wpURL": "https://maps.apple.com/place?q=The%20Museum%20of%20Modern%20Art&auid=7324342225941186006&address=11%20W%2053rd%20St,%20New%20York,%20NY%20%2010019,%20United%20States&ll=40.7617238,-73.9777654", "_styleAttributes": "4:226,6:16,10:0,82:12,85:12,89:1,164:1,193:1", "pointOfInterestCategory": "Museum", "name": "The Museum of Modern Art", "region": { "center": { "latitude": 40.7612829, "longitude": -73.9768677 }, "span": { "latitudeDelta": 0.008983199999995861, "longitudeDelta": 0.01186000000001286 } }, "coordinate": { "latitude": 40.7617238, "longitude": -73.9777654 }, "formattedAddress": "11 W 53rd St, New York, NY 10019, United States", "countryCode": "US", "telephone": "+12127089400", "urls": [ "http://www.moma.org" ], "country": "United States", "administrativeArea": "New York", "administrativeAreaCode": "NY", "locality": "New York", "postCode": "10019", "subLocality": "Manhattan", "thoroughfare": "W 53rd St", "subThoroughfare": "11", "fullThoroughfare": "11 W 53rd St", "areasOfInterest": [ "Manhattan" ], "dependentLocalities": [ "Midtown Center", "Midtown East", "Midtown Manhattan", "Midtown", "North Hudson" ], "timezone": "America/New_York", "timezoneSecondsFromGmt": -14400 } which gives me "pointOfInterestCategory": "Museum" I think pointOfInterestCategory should also be returned in the placeLookup and might be a mapkit error that its not it would also be cool if search autocomplete gave me the poi so i could tag the search result previews (mapbox does this). Unrelated from this topic but coming from mapbox where everything had a mapbox_id i feel like some things like localities like "columbus, Ohio" should still have a place id but maybe the muid serves that purpose idk and just something i should account for. Lastly on my mind is how to manage rate limiting since im just giving the same mapbox js token to all the clients. Of course for server api I can manage my own system for rate limiting logged in users a bit easier but not sure about mapkit js though I can only dream my project is big enough i need to even worry about that lol.
0
0
112
5d
Request of CarPlay Navigation Entitlement when having the Driving Task one
I have the CarPlay Entitlement "Driving Task" and two of my apps use it. Now, in both apps, I have implemented Navigation. I requested the Navigation CarPlay Entitlement when the feature was mature and builds were available in Test Flight, since I wanted to release the new versions of the apps with navigation available both on the iPhone and in CarPlay. I got no answer to my request, so I decided to release the apps with only navigation in the iPhone and the Driving Task functionality in CarPlay, thinking that maybe being live with navigation in the App Store was a requirement. I have asked permission again, and so far, the request is being ignored again. What are the requirements to get the Navigation CarPlay Entitlement? If the app is approved for navigation, is there something else the app must do to get the entitlement? Requirements for CarPlay Entitlements seem quite obscure, are they listed anywhere? Is there a technical problem to move from an existing CarPlay Entitlement to another? Can that be the reason the entitlement has not been granted? Some of my competitors have the CarPlay Navigation entitlement. My use case is the same (in a better app in my opinion, of course). But I am only getting bad reviews because "the app does not include the map in CarPlay" after the big investment in implementing navigation in the apps. Any help or insight would be appreciated.
0
0
115
6d
GPS problem with non moving iphone. Does Apple consider us users as totally infantile?
I had a problem that when traveling by boat the GPS dropped working for the boating app after a few seconds. Then I discovered that when picking up the iphone, the GPS information, that was read by the boating app, returned. At first I had the idea that the GPS signals were weak and my body fluids worked as a kind of extra antenna. But then by accident I noticed that the GPS signal returned when there were some waves that caused the boat to move extra. And so it turns out that Apple has apparently built in a security risk feature that when the iphone is not moving (apart from the very slow movement of the boat) it switches GPS off. Probably is this to protect us from being tracked in some way. An adult approach would leave it to the user to decide if this is a risk the user wants to take (so introduce a setting to turn off this security measure). But not so at Apple. I am getting very tired of trying to find ways to get around the unspecified safety measures that are not under control by me, the user. This is NOT a small minor problem. The app that I use is the most used boating app at least in the Netherlands. The developers got thousands of complaints from apple users and in spite of specifying that location services can be used always as specified by the developers the user should do,all these users couldn’t use the app and basically had to buy an Android phone! Actually the developpers were totally in the dark because it had worked properly before. So Is there a work around?? (I am building now a little device to keep my iphone mechanically moving now as a solution but I prefer as software solution!!!!)
2
0
114
6d
Places with MapKit Questions
Hello, I'm very interested in utilizing Place ID with MapKit. Reference: https://developer.apple.com/videos/play/wwdc2024/10097/ I do have some questions I've been unable to find in documentation or within the demo. Apologies in advance if they have been added since. Are place photos included with the call? It appeared so in the demo just want to make sure as I was unable to confirm in the documentation.) Are star ratings included with the Place ID? Reason: Looking for ways to display top/popular POI around a location. How do rate limits work? Can places be cached? (We're looking to keep saved/bookmarked POI cached to avoid pinging MapKit each time the app is used) How often is place data refreshed? For example if a new restaurant opens in town when will it be available to display. Can search provide place results by name (in and out burger) and by type (burgers in LA)? Would we have to pick one way or the other for search to work in this case? Thanks in advance.
2
0
215
Jun ’24
CLLocationUpdate with the automotiveNavigation configuration spams any location changes
I am working with an app for tracking driving activity. Currently, I have code that combines CLLocationManager location updates with motion data from CMMotionActivityManager. My codebase is not straightforward and requires manual starts/stops, etc. After watching the WWDC session about CLLocationUpdate.liveUpdates (https://developer.apple.com/wwdc23/10180) with the specific LiveConfiguration.automotiveNavigation, I thought it was exactly what I needed. Moreover, the presenter mentioned that it could simplify code and remove the dependency on CMMotionActivityManager. I downloaded the demo project from here https://developer.apple.com/documentation/corelocation/adopting-live-updates-in-core-location, adapted it for iOS 17, and changed CLLocationUpdate.liveUpdates() to CLLocationUpdate.liveUpdates(.automotiveNavigation). However, the result was not what I expected. I received location updates after waking from a stationary state by lightly touching the device, which is not "automotive." Additionally, the changes to LiveConfiguration do not seem to affect the behavior. What did I do wrong? Or what is the point of LiveConfiguration that I missed? Thanks,
2
1
188
1w
Map behaves differently compared to MKMapView
Hey, I have a problem. I was using MKMapView in my app, and in the view where I had a background at the top of the screen, in the example it was Color.red, it extended all the way to the top of the screen. Now, I wanted to switch to the newer Map and I'm seeing an issue because I'm getting a navigation bar that cuts off my color as I indicated in the picture. Does anyone know why this is happening and if there's another way to achieve this? Steps to reproduce: Change MapView() to Map() to see difference import SwiftUI import MapKit @main struct TestAppApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { var body: some View { NavigationStack { ScrollView(.vertical) { Color.red .padding(.top, -200) .frame(height: 200) MapView().frame(minHeight: 300) // change this line to Map } .navigationTitle("Title") .navigationBarTitleDisplayMode(.large) } } } private typealias ViewControllerRepresentable = UIViewControllerRepresentable struct MapView: ViewControllerRepresentable { typealias ViewController = UIViewController class Controller: ViewController { var mapView: MKMapView { guard let tempView = view as? MKMapView else { fatalError("View could not be cast as MapView.") } return tempView } override func loadView() { let mapView = MKMapView() view = mapView } } func makeUIViewController(context: Context) -> Controller { Controller() } func updateUIViewController(_ controller: Controller, context: Context) { update(controller: controller) } func update(controller: Controller) { } } #Preview { ContentView() } I got: I want:
1
0
129
1w
MapKit JS billed requests
Hello, As you stated that "MapKit JS provides a free daily limit of 250,000 map views and 25,000 service calls per Apple Developer Program membership." , I have two questions : are user interactions (zooming, panning, and switching theme) included in the billed map views ? is this limits similar for the enterprise account ? if not, please give us more details. Thanks
0
0
105
1w
Inconsistency in Location Services in macOS Apps
I am encountering some issues with location services in macOS apps. Despite including the necessary keys in the app’s info.plist, I am unable to request user location permission. Here are the details: Cannot request location permission using requestWhenInUseAuthorization(), ie., no location permission grant permissions popup is appearing. The app contains NSLocationUsageDescription in the info.plist. I have also tested by adding NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription, and NSLocationAlwaysUsageDescription, but it didn't work. So to show the location request popup, I was directly(irrespective of the authorizationStatus) requesting location using requestLocation(), which showed the location permission grant permissions popup. But then I encountered another issue. If the popup is left as it is, every time requestLocation() is called a new location request popup appears (which comes after allowing/denying the popup). Also observed that didChangeAuthorization is only called on allowing/denying the last location request pop up. Initial calls to CLLocationManager().authorizationStatus return Not Determined. When I checked the location permission state of my app on launch, I used to get not Determined for some time, even if the permission was granted. Code snippet: private var locationManager: CLLocationManager { let lm = CLLocationManager() lm.delegate = self lm.desiredAccuracy = kCLLocationAccuracyBest return lm } private var currentAuthorizationStatus: CLAuthorizationStatus { if #available(macOS 11.0, *) { return CLLocationManager().authorizationStatus } else { return CLLocationManager.authorizationStatus() } } switch currentAuthorizationStatus { case .notDetermined: print("requesting permission") locationManager.requestWhenInUseAuthorization() case .restricted, .denied: print("location permission is restricted") case .authorizedAlways, .authorizedWhenInUse, .authorized: print("requesting location") locationManager.requestLocation() @unknown default: print("Unknown error occurred") } I would appreciate any guidance or suggestions on how to resolve these issues. Thank you!
0
5
182
1w