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 display an OS alert that prompts permission to use location information
I am creating an app that runs on Mac using objective-c. Since location information permission is required, I implemented the following. // AppDelegate.m #import <CoreLocation/CoreLocation.h> - (void)getLocation { CLLocationManager *locationManager = [[CLLocationManager alloc] init]; [locationManager requestWhenInUseAuthorization]; } - (IBAction)buttonClicked:(id)sender{ [self getLocation]; } Info.plist <key>NSLocationUsageDescription</key> <string>This app requires location information.</string> What I'm hoping for is that when I run this app and press the button, I'd like to see an OS alert asking for permission to use location information, saying "***" would like to use your current location. However, when I try it, no alert is displayed. However, the app name has been added to the "Location Services" item in "Security & Privacy" in System Preferences. How can I display alerts?
0
0
305
Nov ’23
Multi Stop Map Optimisation
I am adding Apple Maps using the API to my Apple IOS to show address to be visited. another feature we require is to have the addresses showing in the best order to be able to visit each one in the fastest time. I am wondering if apple allow to upload multiple addresses via a API and the addresses will be optimised and returned back to my app in the fastest order Is there a SDK that will allow this function?
0
0
401
Nov ’23
The “” value for the NSLocationWhenInUseUsageDescription key isn’t allowed
Hello. I've submitted a small update for my app and i received an email that said: "The “” value for the NSLocationWhenInUseUsageDescription key isn’t allowed " I have values for the above key in English and Greek in InfoPlist files and they are appearing correctly when the app is asking for location permissions. It has been like this for years and i didn't change anything related to this function. Can someone please explain to me why i received this email although i've set everything correctly?
2
0
375
Nov ’23
The MkAnnotationView constructor takes more time in iOS17
As an iOS native MapKit engineer, the MkAnnotationView constructor "initWithAnnotation:reuseIdentifier:" seems to take more time in iOS 17. Just use the code snippet below to measure the time, it constructs 50,000 MKAnnotationView objects. long st = [[NSDate date] timeIntervalSince1970] * 1000; NSLog(@"create annotation view start time = %ld", st); MKAnnotationView *myAV = nil; MKPointAnnotation *anno = [[MKPointAnnotation alloc] init]; anno.coordinate = CLLocationCoordinate2DMake(64, 121); for (int i = 0; i < 50000; ++i) { myAV = [[MKAnnotationView alloc] initWithAnnotation:anno reuseIdentifier:[@"hehe" stringByAppendingString:[NSString stringWithFormat:@"%d", i]]]; } long ed = [[NSDate date] timeIntervalSince1970] * 1000; NSLog(@"create annotation view end time = %ld, interval = %ld", ed, ed - st);` In iOS17, it takes around 2.6s. In iOS16, it takes around 0.9s. This performance degradation between different iOS version(iOS SDK 16 vs. iOS SDK 17) affects our app which uses the native MKMapView. Could someone take a look at this issue or offer any workaround?
0
0
250
Nov ’23
iOS 17 MKMapSnapshotter 'black square' issues
Hi, I'm using MKMapSnapshotter in my app to make a snapshot of routes and I'm using MKMarkerAnnotationView for markers with specific images. This all used to work just fine until iOS 17 arrived. Since then every map that is rendered places a back square around my markers. I have tried everything, searched the whole Internet and there is no way I can solve this... Anyone ran into this and have a way to fix this or is is just a bug we have to live with for now? Thanks in advance!
1
0
426
Nov ’23
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
757
Nov ’23
After granting location permissions to the Geolocation API, it will request permissions again when you refresh the page. This phenomenon is occurring on iOS.
If you refresh the page after initially granting location permissions, you will be prompted for location permissions again and will need to grant permission again. Currently this only occurs on iOS. Is there a way? The tested iOS versions are 16.2 and 17. This is the code implemented when retrieving location information. <script> var options = { timeout: 15000, enableHighAccuracy: true, maximumAge: 86400000, }; function success(pos) { var crd = pos.coords; alert('Your current position is:'); alert(`Latitude : `+crd.latitude); alert(`Longitude: `+crd.longitude); }; function error(err) { alert(`ERROR(): `+err.message); }; navigator.geolocation.getCurrentPosition(success, error, options); </script>
0
0
439
Oct ’23
After granting location permissions to the Geolocation API, it will request permissions again when you refresh the page. This phenomenon is occurring on iOS.
If you refresh the page after initially granting location permissions, you will be prompted for location permissions again and will need to grant permission again. Currently this only occurs on iOS. Is there a way? I launched that web from app and the Safari settings didn't fix the issue. What should I do about this problem? The tested iOS versions are 16.2 and 17. This is the code implemented when retrieving location information. <script> var options = { timeout: 15000, enableHighAccuracy: true, maximumAge: 86400000, }; function success(pos) { var crd = pos.coords; alert('Your current position is:'); alert(`Latitude : `+crd.latitude); alert(`Longitude: `+crd.longitude); }; function error(err) { alert(`ERROR(): `+err.message); }; navigator.geolocation.getCurrentPosition(success, error, options); </script>
0
0
600
Oct ’23
Does CLMonitor work in simulator?
When I run CLMonitor in the simulator, event state remains at default. Although when running the same project on device, state does correctly change between satisfied and unsatisfied. In the simulator I did allow location updates when in use as I did on device. This occurs with the Apple sample code, Monitoring location changes with Core Location associated with the WWDC 2023 session Meet Core Location Monitor. Am I misusing simulator and/or CLMonitor?
1
0
394
Oct ’23
Interactive Markers
I am a new to developing on iOS and I can't seem to find a way to make the Marker from the Map function work with an onTapGesture. My goal is that when the user taps the marker information about the place will pop up. Should I be using something else like mapPin or something else? I am on Xcode 15 and iOS 17.
0
0
252
Oct ’23
CLGeocoder reverseGeocodeLocation is not working for users outside my country
Some errors reported to me recently that my app could not get placemarks outside my country and I test it with a location (2.53,48.83)(in Paris ) and get the error posted bellow, does anyone meet the same error ? (void)reverseGeocodeLocation:(CLLocation *)location completionHandler:(CLGeocodeCompletionHandler)completionHandler; (void)reverseGeocodeLocation:(CLLocation *)location preferredLocale:(nullable NSLocale *)locale completionHandler:(CLGeocodeCompletionHandler)completionHandler API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0)); neither works
0
0
204
Oct ’23
Location Access While Using not available in Securities for app
I have a new app that I am starting using the Map() component in iOS17. That struct, creates a class which is a CLLocationManagerDelegate, and instantiates a CLLocationManager. In the Target's Info settings, I have Privacy - Location Always and When In Use Usage Description Privacy - Location Always Usage Description Privacy - Location Usage Description all three set. I have another Map app with these set which doesn't have this problem, so I am confused about why, in Privacy & Security->Location Services, the App only shows two selections for Location Services. It shows only "Never" and "When I Share" selections with "When I Share" selected. The location manager reports error: The operation couldn’t be completed. (kCLErrorDomain error 1.) after I get the CLAuthorizationStatus(rawValue: 0) auth=CLAccuracyAuthorization(rawValue: 0) value in public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) status change in this callback for the delegate and then call: manager.requestAlwaysAuthorization() manager.startUpdatingLocation() What am I missing here?
0
0
389
Oct ’23
Location Permisison not showing
I'm working on an angular mobile app that runs in ios by using the ionic framework. I want the "Always authorise access to location" option to appear in the settings. And just that. I don't care about the user notification, I just want to manually be able to set the geolocation to "always. I've updated my Info.plist file with the following lines: <key> NSLocationAlwaysAndWhenInUseUsageDescription</key> <string>Always allow Geolocation?</string> <key>NSLocationAlwaysUsageDescription</key> <string>Always allow Geolocation?</string> <key>NSLocationWhenInUseUsageDescription</key> <string>Allow Geolocation?</string> However, the option still does not appear in the settings. Am I missing something? For context: I am completely new to development for ios.
0
0
201
Oct ’23
Mapkit JS - mapkit.MarkerAnnotation title disappeared from below
One time title was showing below the MarkerAnnotation and I noticed, that once it disappeared and now it is showing inside the marker if you click on it. Is it possible to move it back and show it below the marker? The field, that I am using for this purpose is called "title" navigator.userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
1
0
513
Oct ’23
Core Motion on vision pro (specifically getting user's heading relative to north)
hi there, one thing i'm working on for the vision pro requires knowing the user's heading relative to north (magnetic or true). basically it's working with objects located using geo coordinates, and getting an angle of the direction the user is facing relative to them. on iOS and watchOS, i can use CMMotionManager's CMDeviceMotion heading property. looking at the docs it says this heading is there for visionOS, as is the xMagneticNorthZVertical reference frame.. however it seems like there is no magnetometer? it's a bit hard to tell in the simulator since isDeviceMotionAvailable, isAccelerometerAvailable and isGyroAvailable all return false. while isMagnetometerAvailable is a compile error (unavailable in visionOS). is there - or will there be - a way i can get the user's heading relative to north?
2
0
934
Oct ’23
Location Permission Message Not Appearing
This is a app for weather in which i used weatherkit.I have added "privacy - Location when in Usage Description in info of project and also enabled location in features of simulator to Apple.After doing all this ,still the permission message for location is not appearing in app in simulator.Following is my code: import CoreLocation import UIKit //final means this class will not be subclassed final class ViewController: UIViewController, CLLocationManagerDelegate { let locationManager = CLLocationManager() //to access weather data let service = WeatherService() override func viewDidLoad() { super.viewDidLoad() setupView() getUserLocation() } func getUserLocation(){ locationManager.delegate = self locationManager.requestWhenInUseAuthorization() locationManager.startUpdatingLocation() } func getWeather(location : CLLocation){ //asynchoronus task Task { do { //if it throws error //await tells to wait until function gives results let result = try await service.weather(for: location) print("Current : "+String(describing: result.currentWeather)) print("Daily : "+String(describing: result.dailyForecast)) print("Hourly : "+String(describing: result.hourlyForecast)) } catch { //it will be excecuted print(error.localizedDescription) } } } func setupView(){ } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { guard let location = locations.first else { return } locationManager.stopUpdatingLocation() getWeather(location: location) } func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { switch status { case .denied: print("location permission denied") case .authorizedWhenInUse, .authorizedAlways : manager.startUpdatingLocation() print("Location Permission Granted") case .notDetermined : print("location Permission not determined") default: break } } }
0
0
378
Oct ’23
App review rejection on map usage
We request for your kind support, whether it is a previous experience or even a comment will help us a lot! We received rejection for below issue from Apple : ** Guideline 4.0 - Design Your app's location feature is not integrated with the built-in mapping functionality, which limits users to a third-party maps app. Next Steps To resolve this issue, please revise your app to give users the option to launch the native Apple Maps app.** But, our app requires POI(point of interest) on google maps for the service, thus, utilizing apple map's data causes disruption and mismatch of POI data causes issues on business logic (If our app's function was just loading apple map with marker on it, we could solve the issue..) Has anyone faced this rejection issue? We look forward to your kind comment, we are on the verge of going under due to the continuous rejections and errors from app store connect. We are desperate and we request for your kind comments. Sincerely
0
0
404
Oct ’23