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

MapKit .standard doesn't allow for globe view when zoomed out
Hi, I'm writing because I've been trying to set the .standard map style to render as a globe on an iPhone 15 running iOS 17 when zoomed out similar to how it works in Apple Maps but can't find any resources on how to make that happen as every time it appears as a flat 2D map, much unlike the .hybrid and .satellite types. I found another thread on this forum a year ago where someone said .standard was bugged and couldn't become a globe, but I'm honestly quite surprised this issue hasn't been brought up more often.
3
0
421
Jul ’24
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) } } }
5
1
543
Jul ’24
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 "使用高德地图打车去南京南站"
4
0
453
Jul ’24
Guideline 5.1.2 - Legal - Privacy - Data Use and Sharing
The app privacy information provided in App Store Connect indicates the app collects data in order to track the user, including Precise Location. However, the app does not use App Tracking Transparency to request the user's permission before tracking their activity. Apps need to receive the user’s permission through the AppTrackingTransparency framework before collecting data used to track them. This requirement protects the privacy of users. ---How do I fix this problem? I've submitted my app and in return they provided a screenshot of it clearly asking for permission before the app even loads the map in the background. Even though in the screenshot it's asking them for permission they are telling me it's not prompting the user before it starts tracking. I'm lost, help.
1
0
325
Jul ’24
Location interval on the iOS platform, with Flutter's Geolocator
Hey guys. I'm building a cross-platform app using Flutter, which uses the Geolocator package to see how far the user has travelled from their starting point, aviation related. I do allow the user to select their own distance filter value from a set of pre-defined options, which could be as low as a metre, since the app is designed for use over relatively small distances, from say 200m to 1km. Therefore, having a large distance filter value wouldn't make much sense. However, the issue I am having is that with iOS, I can't seem to control the actual sample rate of the user's location. From what I gather, iOS measures the user's location approximately once every second, give or take a bit, but that value cannot be changed. That's quite different to Android, where I can specify this measurement interval to be whatever I want it to be. This lack of ability to control the measurement interval tends to cause quite a lag. When someone first starts to move, they aren't travelling fast enough to cause a noticeable lag. However, when someone's speed picks up, they could be travelling at around 70mph/32m/s (ish). If you're only measuring the user's location once every second, then it's likely they will have travelled over 30m before the next location update, which means the lag distance could potentially be huge relative to the maximum distance they will measure using the app. I do fully appreciate that this is native functionality to iOS but my question really is, is there perhaps a way around this? Is there any way to increase the frequency with which the user's location is retrieved, so that I can reduce this lag? If there isn't, that's no problem at all. I just thought I would ask the question, incase someone has come across this before and found a solution that works. These are the Apple-related settings that I have been able to control with Flutter, for the Geolocator package. Thank you in advance! locationSettings = AppleSettings( accuracy: LocationAccuracy.bestForNavigation, activityType: ActivityType.otherNavigation, distanceFilter: distanceFilterValue, pauseLocationUpdatesAutomatically: false, showBackgroundLocationIndicator: false, );
2
0
521
Jul ’24
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.
3
0
535
Jun ’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.
1
0
491
Jul ’24
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?
5
1
523
Jul ’24
Getting "locationUnknown" as error code in Core Location delegation method didFailWithError for iOS v17.5 and v17.5.1
We have been observing a major spike in Core Location delegation method didFailWithError for iOS v17.5 and v17.5.1. Sharing the implementation of the code at our end - func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { if let clError = error as? CLError { switch clError.code { case .locationUnknown: print("Location unknown") case .denied: print("Access denied") case .network: print("Network error") default: print("Other error: (clError.code)") } } else { print("Other error: (error.localizedDescription)") } } We are observing error responses with error code 0: locationUnknown in iOS 17.5 and above. Is anyone else facing the same issue? Not able to debug this at our end.
2
0
360
Jul ’24
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
413
Jun ’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.
1
0
506
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?
2
0
396
Jul ’24
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
497
Jul ’24