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?
Maps & Location
RSS for tagLearn how to integrate MapKit and Core Location to unlock the power of location-based features in your app.
Post
Replies
Boosts
Views
Activity
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
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.
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?
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
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.
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?
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>
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>
After installing 17.1 on test devices, I am seeing a lengthy difference in requesting a user location. Takes about 4-5 seconds. This issue doesn't occur on 16 or 17.0. Anyone else seeing this problem?
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!
https://maps-api.apple.com/v1/directions
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!
Hi,
We have Bluetooth Hardware and we want to connect to that bluetooth device to open lock in the background when user shakes his phone.Is it possible to do that?
I came accross such apps in the store, but i do not know how to do it.
Regards.
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?
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?
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?
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?
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?
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