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

How to select MapFeature by custom type
If have a custom type (hashable) for map selection: @State var mapSelection: CustomType Map(selection: $mapSelection ) { ... } However, if I want to selet MapFeature, I need to use MapFeature type for the state variable @State var mapSelection: MapFeature But I want to display some Markers by using my CustomType. MapFeature can't be initialized so that I can't map my CustomType to MapFeature to display my Markers. Is there a way to select MapFeature by custom type?
1
0
311
Jan ’24
Is it free to use MapKit's MKLocalSearchCompleter and MKLocalSearch on iOS currently?
Is it free to use MapKit's MKLocalSearchCompleter and MKLocalSearch on iOS currently? I would like to use them for getting geocode. I found this forum. https://developer.apple.com/forums/thread/127493 According to this forum, using MapKit for native app development, there is no cost beyond my Apple Developer Program membership. Is it the same now? sincerely
0
0
382
Jan ’24
Maps searchAutoComplete response field "structuredAddress" always null
Regardless of how much information is provided to the Maps searchAutoComplete API, the response field structuredAddress is always null. This means I have to call the completionUrl afterwards to get a structured address. This consumes our quota and causes unnecessary Maps traffic. Example request, autocompleting "450 Post St, San Francisco": https://maps-api.apple.com/v1/searchAutocomplete? q=450%20Post%20St%2C%20San%20Francisco &resultTypeFilter=Address &limitToCountries=US &lang=en-US responds 2 results with the actual address found, but each having only these fields: - completionUrl - displayLines - location Example: { "results": [ { "completionUrl": "/v1/search?q=450%20Post%20St%20San%20Francisco%2C%20CA%2C%20United%20States&metadata=Ch8KCzQ1MCBQb3N0IFN0EgQIABADEgQIBBAEEgQICRACEjQKIFNhbiBGcmFuY2lzY28sIENBLCBVbml0ZWQgU3RhdGVzEgQIGhACEgQIABADEgQIBBAJGAIyRgoSCQAAAEDg5EJAEQAAAOA9ml7AEM6h0aK1wfKqciA5KQAAAAAAAHlAgvEEAzQ1MIjxBDGa8QQCVVOg8QQAsvEEALrxBABiHAoaNDUwIFBvc3QgU3QsIFNhbiBGcmFuY2lzY2%2BC8QQaNDUwIFBvc3QgU3QsIFNhbiBGcmFuY2lzY2%2BI8QQA2vEEFgkAAABAEf3IQBkAAAAAAAAAACABKAPq8QQAkPIEAQ%3D%3D", "displayLines": [ "450 Post St", "San Francisco, CA, United States" ], "location": { "latitude": 37.78809356689453, "longitude": -122.41002655029297 } }, { "completionUrl": "/v1/search?q=450%20Post%20St%20Napa%2C%20CA%2C%20United%20States&metadata=****", "displayLines": [ "450 Post St", "Napa, CA, United States" ], "location": { "latitude": 38.30093002319336, "longitude": -122.27799224853516 } } ] } Anyone figured this out? Seems buggy to me.
0
2
497
Jan ’24
Map In TabView
In SwitUI when using a map within a tabview the tab bar color is translucent when the map tab is selected. All of the other tabs the tab bar is opaque. In the view that contains the map, if the map is commented out the tab display is opaque, only when the map is displayed. I have an init in the tabview to set the tab bar parameters: // Set Tab Bar appearance let tabbarAppearance = UITabBarAppearance() tabbarAppearance.configureWithOpaqueBackground() tabbarAppearance.backgroundColor = .blue UITabBar.appearance().standardAppearance = tabbarAppearance UITabBar.appearance().scrollEdgeAppearance = tabbarAppearance In the view with the map I use a ZStack to set the entire screen color: ZStack(alignment: Alignment(horizontal: .center, vertical: .top)) { Color(.blue) .ignoresSafeArea(.all) .foregroundColor(.black) VStack(alignment: .center, spacing: 5) { Spacer() Map() Spacer() } } I've tried using .padding(), frame, removing ignoresSafeArea but the tab bar still becomes translucent when the tab is selected. Selecting another tab the color becomes opaque. Any suggestions on how to correct this behavior so the tab bar is opaque for all tabs?
0
0
359
Jan ’24
App store alert to download Apple maps appears twice
I have a code that redirects the user to Google Maps or Apple Maps by pressing the map , when Apple Maps is uninstalled, an alert appears asking the user to download Apple Maps and redirects the user to the App Store, when I select Show in App Store, the user is redirected to App Store, and then the alert is shown again. func openMaps() { let coordinate = CLLocationCoordinate2D(latitude: 52.5162746, longitude: 13.3755153) let mapItem = MKMapItem(placemark: MKPlacemark(coordinate: coordinate)) mapItem.name = "Test" mapItem.openInMaps(launchOptions: [MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDefault]) }
0
0
254
Dec ’23
How to increase the nmea logging period
Hi experts, I got an Ultra2 a while ago and has been using it on walking / running exercise. Recently I came across to this apple site: debug profile and I'm curious about what I would get during the exercise. So I follow the instruction and install the location services profile. After getting the sysdiagnose report, I try to get location related information from it. And it seems that the log from "locationd" and "gpsd" are what I'm looking for. But when I try to look into the nmea information, I found out the sysdiagnose only provide around 10-15 mins of nmea data. For example, let's say I have a walking exercise from 0900 - 1000, but I can only see nmea data from 0945 - 1000. The data from 0900 to 0945 can't be found in the sysdiagnose. Not sure if's the limitation or any setting I can change to increase the logging period? Thanks.
0
0
441
Dec ’23
iOS 17.1 Location Update not terminated When In Use
I activate the conditions as follows Unexpected operation found. Details are below Conditions and configurations used in the testing "Background Modes" Capability with "Location updates" checked on added the info.plist keys: NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription with description monitoring for several beacon regions and invoking startMonitoringSignificantLocationChanges using core location API My app’s location authorization status set ‘WhenInUse’ add UserNotification in func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool. For that reason, If every app launches, a notification will be triggered in AppDelegate method Given the condition above applied, What I expect is that if the location permission is 'when in use', if I leave the app by swiping(I have not closed my application by force using "swiping up in the app-switcher screen"), the app will be suspended in the background after 30 seconds. However, on specific iOS(iOS 16.5.1~ iOS 17.1.2), when I bring the app to the background, the didUpdateLocation function continues to run. I confirmed that the location was updated for over an hour. Other iOS didn’t occur the issue under iOS 16.3.1.(Couldn't confirm 16.4) I wonder if this is normal operation. In addition, I also want to know why it is working differently between iOS versions. Thanks for your help in advance.
0
0
289
Dec ’23
MapKit billing policy on native apps
Thank you all in advance. I've checked the terms and the pre-posted forum related to the same question. https://developer.apple.com/forums/thread/127493 I have plans to use MapSDK in my native app and is critical to know that it really is free to use. Though I've checked the answers, I was wondering if there's a written document that says it's free to use on native apps.
1
0
284
Dec ’23
[Support/Advise plz] High LocationAccuracy in Background but Low/Minimum in Terminated - possible?
Hello Community, Need your help/guidance please. Seeking LocationServices experts who can advise me whether my idea for a valuable add-on feature that I've been trying to add into my app for 2+ months is achievable or not given LocationServices limitations. The Feature: to enable users who would like to be automatically notified whenever they're within X meters from a store that provides them an exclusive discount BUT only when they choose to be notified. Instruction to enjoy the feature is by keeping app open in 'background state' (means opened and kept in background) but not when app is terminated state (completely closed). The state is important because I would like to give users the choice to only receive notifications when they choose to instead of all-time. That is to eliminate unnecessary power consumption fetching location updates constantly when user don't need them (example staying at home, at work, etc), but give them option when they go out. Ideal scenario (after opting in to enable 'Always'): user launches the app, keeps in background, go out shopping/dining/etc and enjoy convenience of being automatically notified whenever about Xmeters from a place that they have an exclusive offer for. Implemented conditions: API is called at fixed time interval whenever user is within about 10 meters from their last location, that is to limit checking only when there is certainty user is within the same place for sometime instead of just walking by (this currently works perfectly, using AccuracyBest), the challenge when user terminates app, LocationServices wakes up again and continues to fetch location updates constantly. The Ask: Is it technically possible that I configure app LocationServices to not wake-up with [AccuracyBest] when terminated but instead use only reduced accuracy (like 'significant location updates' or on 'AccuracyOne/ThreeKilometer')? Ideas/suggestions/recommendations would be much much appreciated
0
0
484
Dec ’23
Geolocation tracking for IOS apps using .net Maui
I'm working on an in-house iOS app designed to help users accurately track their routes during trips. Currently, I've implemented a method to track users when the app is open in the background. However, I'm facing challenges, as the tracking stops when the device is locked for more than 10 minutes. I'm looking for a solution to continuously track a user's geolocation, even if the app is closed or not in use. Specifically, I want to ensure uninterrupted tracking, especially when the device is locked. Here are some key points: Current Method: I'm currently using the Core Location method and a combination of background tasks and a repeating timer to fetch the user's location and update a log for geolocation tracking when the app is open in the background. Issues Faced: The tracking stops when the device is locked for more than 10 minutes. This limitation impacts the accuracy of the route tracking during longer trips. Objective: My goal is to achieve continuous geolocation tracking, even when the app is closed or not actively used, to provide users with a seamless and accurate record of their routes. Platform: The app is developed for iOS using the .net maui platform, and I'm seeking solutions or suggestions that are compatible with the iOS .net maui environment. If anyone has experience or insights into achieving continuous geolocation tracking on iOS, especially when the app is not in use or the device is locked, I would greatly appreciate the assistance.
0
1
609
Dec ’23
Why does audio streaming interfere with iBeacon Ranging and events?
I'm working on an iOS iBeacon app that uses CoreLocation APIs for both ranging and monitoring regions for beacons. I've noticed that if I turn on audio streaming by pairing my phone to my car and making a phone call that's broadcast over the car speakers or running an audio streaming app like Pandora through the car speakers then ranging stops and I receive didExitRegion callbacks. This is with the beacon and the phone within a couple feet of each other and not moving. It happens both with the app in the foreground and background. I guess there's some kind of priority issue going on with the phone's broadcast of audio over BT taking priority of its listening for iBeacons but it seems extreme. My beacons are custom with a broadcast interval of 2 secs and power of 4dB. I'm on the latest iOS 17.x on a recent iPhone and other users have reported the same issue. Is this a well-known issue? Is there some way to mitigate this?
0
0
275
Dec ’23
Handling location updates in background for widget refresh
I'am developing an iOS widget for my weather app, where the user can set the widget to "My location". This means the widget needs to be refreshed on location changes. Since a widget can't run a location manager in the background, apple tech support wrote that you have to setup a location manager in the main app and share the updated location data over App groups to the widget. This part works fine. I also managed to setup a location manager running in the background, but it uses too much battery and shows always the location indicator on top (blue bar) if the app is running, but I don't need this since its not a navigation app or something similar. How to configure a lightweight location manager running in the background? class WidgetLocationManager: NSObject, CLLocationManagerDelegate { static let shared: WidgetLocationManager = WidgetLocationManager() let manager = CLLocationManager() override init() { super.init() manager.delegate = self manager.desiredAccuracy = kCLLocationAccuracyKilometer manager.distanceFilter = 1000 manager.allowsBackgroundLocationUpdates = true manager.pausesLocationUpdatesAutomatically = false manager.activityType = .other manager.showsBackgroundLocationIndicator = false } func setupWidgetLocationManager() { manager.requestWhenInUseAuthorization() manager.startUpdatingLocation() manager.startMonitoringSignificantLocationChanges() } func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { if manager.authorizationStatus == .notDetermined || manager.authorizationStatus == .denied || manager.authorizationStatus == .restricted { manager.stopUpdatingLocation() manager.stopMonitoringSignificantLocationChanges() } if manager.authorizationStatus == .authorizedAlways || manager.authorizationStatus == .authorizedWhenInUse { manager.startUpdatingLocation() manager.startMonitoringSignificantLocationChanges() } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { if let newestLocation = locations.last { UserDefaults(suiteName: "group.com.***")?.set(Double(newestLocation.coordinate.latitude), forKey: "newest_location_latitude") UserDefaults(suiteName: "group.com.***")?.set(Double(newestLocation.coordinate.longitude), forKey: "newest_location_longitude") UserDefaults(suiteName: "group.com.***")?.set(Double(newestLocation.altitude), forKey: "newest_location_altitude") WidgetCenter.shared.reloadAllTimelines() } } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { } } Capability for background modes location is set, also mandatory strings in info.plist for location privacy info.
1
1
624
Nov ’23
How can obtain Public Transportation Information with MapKit
Can Mapkit show me details about bus stops, train stations, underground and overground stops, or other public transportation locations based on a specific latitude and longitude? If you check the Google Maps picture I shared, I marked all the public transportation spots near Elephant & Castle in London. This includes bus stops, the Elephant & Castle Underground station, and the Elephant & Castle Rail station. Additionally, tapping on these spots brings up an alert with more info, like which buses are coming or details about train lines.
0
0
505
Nov ’23
Google crush my app.
I am currently facing a critical issue with the Google Maps integration in my iOS app. The application functions flawlessly on my personal device during development; however, when I upload it to the Apple Store, users on their iPhones experience frequent crashes. The problem seems to be specifically tied to the Google Maps functionality within the app. Despite thorough testing on my end, the discrepancy between the local environment and the App Store release persists. I am seeking assistance from fellow developers to help me identify and rectify the root cause of this problem. Any insights, suggestions, or debugging tips would be greatly appreciated to ensure a smooth and reliable user experience for all. Thank you in advance for your expertise and support in resolving this issue.
0
0
383
Nov ’23
MapKit UI - Marker / Protocol help
Hi , I'm trying to teach myself the new Mapkit code. Can someone help me fix the code below: I'm getting the following error on Line 19: Initializer 'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:annotationItems:annotationContent:)' requires that 'Marker' conform to 'MapAnnotationProtocol' import MapKit struct IdentifiableAnnotation: Identifiable { let id = UUID() var annotation: MKPointAnnotation } struct ContentView: View { @ObservedObject var locationManager: LocationManager @State private var showUserProfile = false @State private var showNotifications = false @State private var showFriendz = false @State private var courtAnnotations: [IdentifiableAnnotation] = [] var body: some View { NavigationView { ZStack(alignment: .bottom) { Map(coordinateRegion: $locationManager.region, interactionModes: .all, showsUserLocation: true, userTrackingMode: .none, annotationItems: courtAnnotations) { item in Marker(<#LocalizedStringKey#>, coordinate: item.annotation.coordinate) } .edgesIgnoringSafeArea(.all)
2
1
461
Nov ’23
Mapkit JS map initialisation fails from China
Hello, I am facing an issue with mapkit JS map when it is accessed from China. From other regions maps render and display fine, but when user from China tries it, it throws 401. Signed JWT token is shared for all regions (without origin field) and is still valid and verified on JWT.io (and it works on other regions so it should not be the problem). Does mapkit js work for China users as it is stated that it does? Thanks in advance, Marko
3
0
614
Nov ’23
Mapkit JS remove road annotations
Right now my map is littered with road annotations (interstate and highway markers) that are quite distracting and not at all relevant to my application. Is there a way to turn them off? I already tried mapkit.pointOfInterestFilter but the categories do not include the road annotations. I can't find anything else. Does anyone know?
1
0
392
Nov ’23