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

About popup asking user if they want to continue allowing the app to use location in the background
Hi everyone,I want to ask and to better understand about the popup that iOS will occasionnally ask the user like :"Weather" has been using your location in the background. Do you want to continue allowing this ?How often dose this occur nad how do they determine when to ask ? And is it possible to prevent this to show to the user ?I can't find any documentation, the only explanation i can find is from the presentation from WWDC 2014 video "What's New in Core Location".Thank,Pat.
10
0
11k
Jun ’16
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: &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!) -> 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
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.4k
Apr ’17
Clustering stop working after removing all annotations
Hi!I noticed a strange behavior on MapKit when using the iOS 11 clustering feature.If you add some annotations on a map (with same clusteringIdentifier and same displayPriority) MapKit will correctly merge together annotations that are close.The problem is that if you remove all the annotations and then you add them back the map will no more merge the annotation together. It’s like the clustering feature simply stop working.I don’t really know if it is a bug or if I miss something.Someone else have noticed this?Alan
6
0
4.9k
Dec ’17
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
922
Jun ’18
MKMarkerAnnotationView being clipped
I am trying to create a map snapshot, using MKMapSnapshotter that includes a MKMarkerAnnotationView. The issue I am facing is that the MKMarkerAnnotationView is being clipped. I can see that the frame of my MKMarkerAnnotationView is 28*28, which seems to be too small. My code: if let image = snapshot?.image { /* Create the annotation */     let annotation = MKPointAnnotation()     annotation.coordinate = center /* Create the annotation view */     let annotationView = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: nil)     annotationView.glyphImage = UIImage(named: "mappin")     annotationView.isSelected = true /* annotationView.frame would show the width and height being 28 */ /* Start the context */     UIGraphicsBeginImageContextWithOptions(image.size, true, image.scale) /* Draw the image from the MKMapSnapshotter in the context */     image.draw(at: CGPoint(x: 0, y: 0)) /* Define the rect where the Annotation View should be rendered in */     let rect = CGRect(x: snapshot!.point(for: center).x, y: snapshot!.point(for: center).y, width: annotationView.frame.width, height: annotationView.frame.height) /* Draw the Annotation View in the context */     annotationView.drawHierarchy(in: rect, afterScreenUpdates: true)     let finalImage = UIGraphicsGetImageFromCurrentImageContext()     UIGraphicsEndImageContext() }
1
0
942
Jul ’20
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.2k
Aug ’20
RealityKit : Why ARGeoTrackingConfiguration is not available everywhere ?
Hi, The ARkit is a great tool, I have my small app doing things, and it's fun! but I wanted to try to migrate from ARWorldConfiguration to ARGeoTrackingConfiguration - https://developer.apple.com/documentation/arkit/argeotrackingconfiguration and then we can see that this configuration is limited to a couples of USA only cites. But I can't manage to figure Why and if, in the near future, this will be expanded world wide ?
2
0
1.3k
Jan ’21
Xcode 13.1 iOS 15.0 simulator missing location privacy settings
When I run an app that uses location services on the Xcode 13.1 simulator for iOS 15 the location privacy settings are missing. If you go to the settings on the simulator under privacy the section for location services is missing. The exact same thing on a physical iPhone running iOS 15.0 does show the location settings under privacy in the settings app. Where did the settings for location privacy go? In order to test using the simulator a developer needs to be able to turn those settings on and off, like turning off precise location to see how an app responds.
12
6
15k
Oct ’21
iOS 14+ GPS EXIF data from CAMERA
I am building an iOS app that uses the phone's GPS EXIF data from both camera and image library. My problem is that I while I am able to get GPS data from images in the phone's library, I have not been able to get any GPS data when using the camera within my app. I first built this app about a year ago and at that time I was able to get GPS data from both the library AND the camera from within the app. I believe that at that point I was still building for iOS 12.. I believe that the new security features that came with iOS 13 or 14 now dissalow my app's access to the GPS data when using the camera. This issue is new as of iOS 13 or 14. The code I had was working fine with earlier versions of iOS I am having no issues with getting GPS from the EXIF on the device library images. Images taken with the NATIVE IOS CAMERA APP are saved to the library with full GPS data.  - However I am not able to get GPS data directly from camera image EXIF when using the camera from within my app. When saving an image taking by the camera from within my app the image is saved to the library with NO GPS data. I am able, at any time, to ask the device for current GPS coordinates. As far as I can tell, device settings are all correct. Location services are available at all times.  My feeling is that iOS is stripping the GPS data from the EXIF image before handing the image data to my app. I have searched Apple developer forums, Apple documention, Stack Exchange, on and on for over several weeks now and I seem no closer to knowing if the camera API even returns this data or not and if it will be necessary for me to talk to the location services and add the GPS data myself (which is what I am working on now as I have about given up on getting it from the camera). Info.plist keys I am currently setting:  LSRequiresIPhoneOS  NSCameraUsageDescription  NSLocationAlwaysUsageDescription  NSLocationWhenInUseUsageDescription  NSMicrophoneUsageDescription  NSPhotoLibraryUsageDescription  NSPhotoLibraryAddUsageDescription Am I missing some required plist key? I have been searching and searching for the name of a key that I might be missing but have found absolutely nothing other than people trying to hack some post-camera device location merging. This has been very frustrating.. Any insite is appreciated Is it currently possible to get GPS data directly from the camera's EXIF output any more? Do I need to ask the device for the current GPS values and insert the GPS data into the image EXIF on my own? Is there any example code of getting GPS data from the camera? Is there any example code of inserting GPS data into the Exif before saving the file to the device? Sample swift code which processes the camera image.   func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {     let pickedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage     // let pickedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage     // using editedImage vs originalImage has no effect on the availabilty of the GPS data     userImage.image = pickedImage     picker.dismiss(animated: true, completion: nil)   }
4
2
1.8k
Jan ’22
MapKit - Look Around - isNavigationEnabled not working?
I'm adding Look Around into my app, but settings isNavigationEnabled to true or false does nothing. This bool is set to true by default, and my understanding is that it will enable the user to navigate around the location. I tried setting it to false and that didn't change the experience as the user was able to rotate the camera 360 degrees, but not move around freely in the area. Is this by design or am I missing something? Note: I'm on the latest Xcode 14 beta (beta 6). Here is my basic implementation: let lookAroundRequest = MKLookAroundSceneRequest(coordinate: location.coordinate!) lookAroundRequest.getSceneWithCompletionHandler { lookAroundScene, error in guard error == nil, lookAroundScene != nil else { return } let lookAroundVC = MKLookAroundViewController(scene: lookAroundScene!) lookAroundVC.pointOfInterestFilter = .includingAll self.present(lookAroundVC) }
3
0
1.5k
Aug ’22
MapKit JS JWT doesn't work when the request is from China
I've got a working JWT token for MapKit JS. However, when the user's IP shows them in China, the console says "Initialization failed because the authorization token is invalid". The pins work and show correctly, but the map images do not appear. I know that Apple Maps work in China, which is why I chose Apple as the vendor. Is there something I need to do to allow my Chinese audience to view my maps or use my JWT token?
2
1
1.6k
Sep ’22
Electron app crash on open in Test flight
Hello guys, I have an Electron app build with electron forge (v6.0.4). I was able to pass the verification via Transporter and able to install it from TestFilght. but the app was not able to run. I have tried to run the app from Terminal, I got the following error message: FATAL:mach_port_rendezvous.cc(142)] Check failed: kr == KERN_SUCCESS. bootstrap_check_in com.xxxx.yyyyy.MachPortRendezvousServer.39844: Permission denied (1100) Then I looked into the system logs, I found: 2022-12-17 22:03:10.473560 (gui/501 [100006]) : denied lookup: name = com.apple.CoreLocation.agent, flags = 0x1, requestor = AppName[39844], error = 159: Sandbox restriction 2022-12-17 22:03:10.473654 (system) : denied lookup: name = com.apple.locationd.desktop.registration, flags = 0x8, requestor = AppName[39844], error = 159: Sandbox restriction 2022-12-17 22:03:10.482191 (system) : failed lookup: name = com.epsecurity.bdconnectorservice, requestor = BDCoreIssues[162], error = 3: No such process 2022-12-17 22:03:10.537167 (gui/501/com.apple.xpc.launchd.unmanaged.AppName.39844 [39844]) : added unmanaged active 2022-12-17 22:03:10.537647 (gui/501 [100006]) : failed activation: name = com.xxxx.yyyy.MachPortRendezvousServer.39844, flags = 0x1, requestor = AppName[39844], error = 1: Operation not permitted I have tried with/without com.apple.security.personal-information.location in my entitlements file, but looks like no difference. I have spent many days on it, anyone can help?
2
0
1.1k
Dec ’22
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
1.9k
Dec ’22
MKMapSnapshotter/VectorKit crash since iOS 16
We "recently" started getting crashes when taking a satelite map snapshot in app using MKMapSnapshotter. We realized that all crashes have a common denominator that they all happened on iOS 16. The code that creates the snapshot has been unaltered and working without crashes since 2018 up until the release of iOS 16. This is likely some bug in the SDK. let options = MKMapSnapshotter.Options() let location = CLLocationCoordinate2D(latitude: latitude, longitude: longitude) options.mapType = .satelliteFlyover options.size = size options.camera = MKMapCamera(lookingAtCenter: location, fromDistance: distance, pitch: 0, heading: 0) let snapshotter = MKMapSnapshotter(options: options) snapshotter.start(completionHandler: completionHandler) Crashed: com.apple.maps.snapshotter 0 VectorKit 0x95d8f0 ggl::Renderer::removeDebugRenderer(std::__1::shared_ptr<ggl::DebugRenderer> const&) + 40 1 VectorKit 0x5cc588 md::DebugConsoleManager::~DebugConsoleManager() + 120 2 VectorKit 0x5cc588 md::DebugConsoleManager::~DebugConsoleManager() + 120 3 VectorKit 0x14e4f4 std::__1::unique_ptr<md::DebugConsoleManager, std::__1::default_delete<md::DebugConsoleManager> >::reset(md::DebugConsoleManager*) + 32 4 VectorKit 0x1b4a48 -[GGLImageCanvas .cxx_destruct] + 36 5 libobjc.A.dylib 0x14a4 object_cxxDestructFromClass(objc_object*, objc_class*) + 116 6 libobjc.A.dylib 0x621c objc_destructInstance + 80 7 libobjc.A.dylib 0xf9d0 _objc_rootDealloc + 80 8 VectorKit 0x145958 -[GGLImageCanvas dealloc] + 44 9 VectorKit 0x6eacc md::MapEngine::~MapEngine() + 1644 10 VectorKit 0x133e6c md::MapEngine::~MapEngine() + 16 11 VectorKit 0x33b30 -[VKMapSnapshotCreator softDealloc] + 352 12 VectorKit 0x33778 __42-[VKMapSnapshotCreator renderNextSnapshot]_block_invoke + 904 13 libdispatch.dylib 0x24b4 _dispatch_call_block_and_release + 32 14 libdispatch.dylib 0x3fdc _dispatch_client_callout + 20 15 libdispatch.dylib 0xb694 _dispatch_lane_serial_drain + 672 16 libdispatch.dylib 0xc214 _dispatch_lane_invoke + 436 17 libdispatch.dylib 0x16e10 _dispatch_workloop_worker_thread + 652 18 libsystem_pthread.dylib 0xdf8 _pthread_wqthread + 288 19 libsystem_pthread.dylib 0xb98 start_wqthread + 8
7
1
2.1k
Jan ’23
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