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

can I get current location in widgetKit
As far as I can tell in my app I am requesting current location in the app and in the widget the same, but I am not ever seeing my widget make the network call the I would expect if current location was successful. I have the same info plist permissions for usage and request for access in both the app and the widget ( runs the same shared code ). My question is does widgetKit work to get core location similar to the the way that today extensions work. or do I need to cache it from the phone app and hope its been updated ?
4
0
2.3k
Aug ’20
MapKit Custom 3D Models
Dear Apple Team and everyone who has experience with MapKit. I am building an app where I need to hide some 3D models and replace them with my custom 3D meshes using SceneKit. Up until now I was using Mapbox it allows to get mesh row data to reconstruct all maps 3D. Is there something like this possible with MapKit? Use cases Say you navigated to Kennedy Space Center Launch Complex 39 and there is no 3D model of actual building. I would like to be able to hide simple massing and replace it with my model. In 3D Satellite VIew some areas have detailed meshes. Say London The Queen's Walk. I would like to make specific area flat so I can place my 3D model on top of Satellite 3D View to illustrate new structure or building. Last one. Is it possible to change existing buildings colours? I know it is possible transparency Thank you @apple
2
1
2.0k
Dec ’22
MapKitJS sourcemap CDN URLs do not resolve
Hi, At the bottom of https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.core.js there is a sourcemap comment: //# sourceMappingURL=https://mw-ci1-mapkitjs.geo.apple.com/admin/source-maps/5.75.4/source-maps/mapkit.core.min.js.map. https://mw-ci1-mapkitjs.geo.apple.com does not resolve. Nor does https://geo.apple.com. Is there a link to the sourcemap for mapkit.core.js, as well as the bundles at /libs that work? Many thanks.
5
2
1.7k
Jan ’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
How to detect MapKit Map panning/scrolling ended
Hello, I'm trying to figure out how to detect when user stops scrolling (panning) the map. The problem: I have a MapAnnotation that I want to always keep in the centre, even is user is panning/scrolling the map. When map is open first time, the original annotation location is user's current location. I request the name of the location to display it on top of the annotation. when user moves the map around, I want to track when he stop this action and select a location in the centre of map's new region and display the a location's name on top of the annotation I can't use .onChange() because region centre changes constantly as user moves the map, because it causes to many requests for location's name DragGesture .onEnded() is never called, so I have no idea when customer stops moving the map So my question is - how to detect in this case when customer stopped moving the map? Have anyone faced the same problem? Any ideas how to solve it?
2
1
1.6k
Apr ’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
203
Oct ’23
Granularity/Accuracy of delivered locations with live updates
First of all : Thanks for the great presentation (wwdc2023-10180), Siraj ! This new, simple API looks like what we've been looking for for easy manageable background location updates with 'automatic battery drain minimization' :-) There were two questions that came to my mind. As far as I understood, the CLLocationUpdate.LiveConfiguration is used to help the location services to improve the location fixes. Are there other options planned to specify the granularity of delivered locations e.g., how accurate the locations need to be (as the desiredAccuracy and distanceFilter settings for the olden CLLocationManager)? Does the Implementation switch between significant location changes and regular, more expensive ways (like GPS hardware) or just deliver the most feasible accuracy available at the time of notification? I'm just curious - if I get the most feasible granularity, everything is fine for me anyway :-) Thanks again, Michael
1
0
651
Jun ’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
Dynamically resize Annotation's callout
Hi,I've got annotations on a MKMapView and I added a custom view inside the detailCalloutAccessoryView. This custom view performs a request and should present various amount of data depending on the request's reply. Basically, I can show 1 or 2 rows of data.Sometimes, when I touch an annotation and the result is only one row, the callout is not resized. However, if I dimiss the annotation and select it once again, it is rendered correctly.What is the "right" way to make it work? Using a intrinsicContentSize, or calling layoutIfNeeded (already tried, did not work)Thanks for your help.
1
0
955
Jun ’18
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
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
200
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
932
Oct ’23
macos sonoma - unable to change time zone
hi, everyone! i travelled to a different time zone and the time has not updated to my new location. i seem to remember this worked ok before sonoma. system settings - privacy & security - location services - system services - details - setting time zone ON (if this is changed to off it does not stay off, if i leave that window pressing done, when i open that setting again it is still set to on, so changing it has no effect) system settings - general - date & time all set to ON (if Set time zone automatically using your current location is set to off the the Time zone stays greyed out and cannot be changed and only the Closest city can be changed, which is of no use as cities to select from are still not in the time zone i want to change to). this is probably a bug in the new macos sonoma and just wanted to make this known and hopefully have a solution to it. thank you!
10
4
4.7k
Jun ’23
Using MKTileOverlay and MKPolyLine lose tiles at zoom.
If I have a mapview with a tileoverlay and polyline, the view works until I zoom in close. When zoomed in, the tiles under the polyline don't render, but other tiles not under the polyline do. Xcode 7.3.1 targeting ios 9.3.Below is the minimal test case I have come up with to show this. Any ideas how to debug further? If I remove the polyline overlay, zoom works perfectly fine for all tiles. class MyController: UIViewController, MKMapViewDelegate { @IBOutlet weak var mapView: MKMapView! var overlay:MKTileOverlay = MKTileOverlay(URLTemplate: "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}.jpg"); override func viewDidLoad() { mapView.delegate = self mapView.showsUserLocation = true; overlay.maximumZ = 15; overlay.minimumZ = 12; overlay.canReplaceMapContent = true mapView.addOverlay(overlay); var points: [CLLocationCoordinate2D] = [CLLocationCoordinate2D]() points.append(CLLocationCoordinate2D(latitude: 40.7608, longitude: -111.8910)); points.append(CLLocationCoordinate2D(latitude: 40.8894, longitude: -111.8808)); var polyline = MKPolyline(coordinates: &amp;points, count: points.count) mapView.addOverlay(polyline) let region = MKCoordinateRegion(center: points[0], span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)) mapView.setRegion(region, animated: false) } func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -&gt; MKOverlayRenderer! { if overlay is MKPolyline { var polylineRenderer = MKPolylineRenderer(overlay: overlay) polylineRenderer.strokeColor = UIColor.blueColor() polylineRenderer.lineWidth = 5 return polylineRenderer } else if (overlay is MKTileOverlay) { let renderr = MKTileOverlayRenderer(overlay: overlay) return renderr } return nil } }
1
1
1.1k
Jul ’16
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
External Bluetooth GPS data source
Hello everyone. I need a clarification with Core Location, please help.How exactly is GPS data passed from external GPS source that is connected via Bluetooth? After some googling I found two separate points:Core Location (CLLocationManager) is responsible only for internal GPS receiver data. For external BT sources I need to use EAAccessory and read NMEA protocol.When I connect an external source, internal GPS is switched off instantly and CLLocationManager starts providing its data. So it must work OK.Thing is, I don't have an external source to test it and I'm not that experienced in BT.I have a report that people cannot use external GPS source with my app (I use Core Location only). Though I also have an info that all navigation apps support external GPS source. So they've already solved this?Or maybe I should check Core Bluetooth out for this?My question is kind of close to this one:https://forums.developer.apple.com/thread/69717?q=gpsMaybe MFi really has a relation to that? And something can depend on GPS device being MFi or being not MFi?Or this one:https://forums.developer.apple.com/message/31679#31679Seems much closer to my topic. So if I got it right, all MFi-supported external GPS data sources should work as is via Core Location?If that's true, is all CLLocation data valid there (when using external source)? Or just altitude and position?
3
2
3.5k
Apr ’17
MapKit JS stuck in dark mode
I'm seeing a strange situation where my MapKit JS page is stuck in dark mode. I'm trying to implement a custom version of the sample code "Callout Accessory Views" from here: https://maps.developer.apple.com/sample-code/accessory-views/ I have 2 simple examples of my implementation of this. I like the simple look of the annotation. I can customize the left and right accessory. Here are 2 samples of my map: https://zrl.me/debug1.html https://zrl.me/debug2.html I really want something that looks like debug1.html, but it is ALWAYS shown in dark mode. When I inspect the element where the annotation says "Washington, DC", there is a CSS class ".mk-dark-mode". My Mac does not use Dark mode, or Auto, but somehow this page always shows Dark. It happens at night and during the day. Researching this further, I saw that there area a couple ways of fixing this. In MapKit JS, you should be able to assign: colorScheme: mapkit.Map.ColorSchemes.Light In the Map constructor. This does not force the map into Light mode for me.. More research shows that this should force the entire page into light mode, but it does not work here: <meta name="color-scheme" content="light only"> The difference between debug1.html and debug2.html is that debug1.html sets: accessoryViewLeft.className = "left-accessory-view"; When this class is set, since the callout is actually a bit like a speech bubble, it creates a SVG shape behind the annotation. It looks like when either the left or right sides of the callout have a background-color applied, MapKit JS tries to smartly adjust the coloration of the bubble, and forces the right-side to have a WHITE background, instead of a contrasting dark background. I have a few simple questions, any one of these could help resolve this issue? Does anyone know why my instance of this is being forced into dark mode? This does not happen in the sample code. Does anyone know how to force the map into light mode? Is there a way to stylize the main section of the annotation callout? Is there a way to change/force the stylizing of the speech bubble to have something other than a white background-color on the second half of the gradient on the SVG?
1
0
566
Sep ’23