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

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
299
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
541
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
1k
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
521
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
708
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
468
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
303
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
245
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
468
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
246
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
613
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
1.1k
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
440
Oct ’23
Getting geo-locationn on Safari embedded in Watch OS
Wondering if anyone has had any luck with getting the geo-location while viewing a web page in mobile Safari on Watch OS? I've updated my phone and watch to the latest versions. The code I'm using is standard Javascript for geolocation such as navigator.geolocation.getCurrentPosition(showPosition, showPositionError); Works fine when I run it in Safari on my laptop, but when I try to run the same thing on apple watch in embedded web browser, get an "Access Denied" error, which would imply that I have some permission set wrong either on the watch or the paired iPhone. I've messed with many of those settings and nothing seems to be working. Wondering if it's stated somewhere that it simply won't work so I don't continue chasing my tail on something that was designed not to work.
1
1
546
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
487
Oct ’23
Can you make a Marker selectable?
In the initial Xcode 15/iOS 17 Beta selecting a Marker would give a visible indication that the marker was selected without setting the selection. This is the code I used. struct ContentView: View { let location = CLLocationCoordinate2D(latitude: 37.0, longitude: -122.0) @State private var position: MapCameraPosition = .automatic @State private var selectedItem: MKMapItem? var body: some View { VStack { Text(selectedItem == nil ? "Nothing Selected" : selectedItem?.name == nil ? "No name" : selectedItem!.name!) .bold() .padding() Map(position: $position, selection: $selectedItem) { Marker("Marker", coordinate: location) .tag(1) .tint(.red) } } .padding() } } I submitted feedback and things changed in Beta 3. Now I can not select the Marker. That's not the direction I'd hoped to see. Am I doing something wrong or is there no way to select a Marker placed on a map?
2
1
1.4k
Jul ’23