Display map or satellite imagery from your app's interface, call out points of interest, and determine placemark information for map coordinates using MapKit.

MapKit Documentation

Posts under MapKit tag

154 Posts
Sort by:
Post marked as Apple Recommended
1.7k Views
Does anyone know if there is a way to move the "Maps" and "Legal" text in the Map SwiftUI view? App Store Guidelines require that the text be shown, but if you are trying to add some type of sheet or view overlay for some of the map, I can't seem to find a way to add extra bottom padding to this text.
Posted
by
Post not yet marked as solved
1 Replies
870 Views
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() }
Posted
by
Post not yet marked as solved
2 Replies
767 Views
Does market provide any information concerning the road speed limit? ou max speed per road?
Posted
by
Post not yet marked as solved
5 Replies
2.9k Views
Hi guys. I just started developing my own apps and I am very new to Swift and development for iOS, but I had an idea for a great app that utilizes the "Look around" feature that Maps provide, but I can't find any information about this in the documentation for MapKit. Does anyone know if it currently possible to enable a view for this? Thanks in advance!
Posted
by
Post not yet marked as solved
6 Replies
2.8k Views
I search places with the MKLocalSearchCompleter and refine the results when the tableView cell is selected. When a MKLocalSearchCompletion is selected and MKLocalSearch.Request() is started, I get these Errors (example selects Los Angeles):  According to my research this is a very rare problem?! [SearchAttribution] No matching attribution source found for org.volunteermatch ... (+4 other domains) Error loading attribution info for identifier org.volunteermatch from geod: Error Domain=GEOErrorDomain Code=-8 "No matching attribution source found for org.volunteermatch" UserInfo={NSDebugDescription=No matching attribution source found for org.volunteermatch} ... (+4 other domains) These are the instance variables in a TableViewController: var searchCompleter = MKLocalSearchCompleter() var searchResults = [MKLocalSearchCompletion]() This code is running everytime the search term is changed: searchCompleter.queryFragment = text searchCompleter.resultTypes = .address searchCompleter.region = region In tableView … didSelectRowAt… this code is executed: let selectedItem = searchResults[indexPath.row] let searchRequest = MKLocalSearch.Request() searchRequest.naturalLanguageQuery = selectedItem.title searchRequest.resultTypes = .address let search = MKLocalSearch(request: searchRequest) search.start { (response, error) in guard let coordinate = response?.mapItems[0].placemark.coordinate else { return } // send to mainVC self.delegate?.userSelectedPlace(coordinate: coordinate) }
Posted
by
Post not yet marked as solved
12 Replies
4.4k Views
Using the new version Xcode 13.0 beta, exception throws when init apple map view in Simulator  self.mapView = MKMapView() 'NSInvalidArgumentException', reason: '-[MTLDebugDevice traceStream]: unrecognized selector sent to instance 0x7f946af781d0' *** First throw call stack: ( 0  CoreFoundation           0x00007fff203f6fa7 __exceptionPreprocess + 242 1  libobjc.A.dylib           0x00007fff2019cbe7 objc_exception_throw + 48 2  CoreFoundation           0x00007fff20405b28 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0 3  CoreFoundation           0x00007fff203fb46b forwarding + 1412 4  CoreFoundation           0x00007fff203fd598 _CF_forwarding_prep_0 + 120 5  libMTLCapture.dylib         0x0000000105f65a0e libMTLCapture.dylib + 55822 6  libMTLCapture.dylib         0x0000000105f6425d libMTLCapture.dylib + 49757 7  VectorKit              0x00007fff3181cf7d -[MetalLayer initWithDevice:sRGB:] + 73 8  VectorKit              0x00007fff30fcd059 _ZNK2md6Device8newLayerEv + 179 9  VectorKit              0x00007fff315cf63d -[MDDisplayLayer createRenderTarget] + 110 10 VectorKit              0x00007fff31015cf9 -[VKMapView _createDisplayLayer] + 36 11 VectorKit              0x00007fff3101c8b9 -[VKMapView initShouldRasterize:inBackground:contentScale:auditToken:mapViewPurpose:] + 1575 12 MapKit               0x00007fff30b08f22 -[MKBasicMapView initWithFrame:andGlobe:shouldRasterize:] + 408 13 MapKit               0x00007fff30a226ee -[MKMapView _commonInitFromIB:gestureRecognizerHostView:locationManager:showsAttribution:showsAppleLogo:] + 1601 14 MapKit               0x00007fff30a23448 -[MKMapView initWithFrame:] + 251 15 UIKitCore              0x00007fff254abce5 -[UIView init] + 44 libc++abi: terminating with uncaught exception of type NSException dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/jli1/Library/Developer/Xcode/DerivedData/erpclfvpzelgfubxbfquzihyqiou/Build/Products/Debug-iphonesimulator:/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib:/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMTLCapture.dylib *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MTLDebugDevice traceStream]: unrecognized selector sent to instance 0x7f946af781d0' terminating with uncaught exception of type NSException CoreSimulator 772.1 - Device: iPhone 12 Pro (E9648567-BCB1-4314-A315-3B0C8B142328) - Runtime: iOS 15.0 (19A5261u) - DeviceType: iPhone 12 Pro
Posted
by
Post not yet marked as solved
1 Replies
456 Views
Guys how is it possible to set a map type like hybrid, satellite etc on the following code? Thanks in advance! import MapKit struct MapView: View {         @State private var region: MKCoordinateRegion = {                  var mapCoordinates = CLLocationCoordinate2D(latitude: 6.600286, longitude: 16.4377599)         var mapZoomLevel  = MKCoordinateSpan(latitudeDelta: 70.0, longitudeDelta: 70.0)                  var mapRegion = MKCoordinateRegion(center: mapCoordinates, span: mapZoomLevel)         return mapRegion     } ()          let locations: [NationalParkLocation] = Bundle.main.decode("locations.json")     var body: some View {               Map(coordinateRegion: $region, annotationItems: locations, annotationContent: { item in                   MapAnnotation(coordinate: item.location) {                 Image("logo")                     .resizable()                     .scaledToFit()                     .frame(width: 32, height: 32, alignment: .center)             }                      })       } }
Posted
by
Post not yet marked as solved
3 Replies
1.4k Views
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) }
Posted
by
Post not yet marked as solved
19 Replies
7.2k Views
So I'm trying to use MapKit in a SwiftUI project targeting iOS/iPadOS. MapKit is obviously pretty limited in SwiftUI, but I've been getting warnings trying to set up basic annotations for the user to interact with. When I use a basic MapMarker everything is fine (although it's hard to do anything with it), but whenever I do anything with MapAnnotation, I get this warning in Xcode (14.0.1) whenever I move the map around: [SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior. I'm no SwiftUI expert, and I get how to fix this issue when binding in something like a sheet, but I don't see how what I'm doing with MapAnnotation should be causing this. It looks like a bug to me, possibly complaining about the $region binding, but maybe I'm wrong? Am I doing something wrong or is this a bug? Below is some sample code that reproduces this easily for me (just launch an app with the below code and then drag the map around to see the constant warnings in Xcode). It's mostly an example from here: https://www.hackingwithswift.com/books/ios-swiftui/integrating-mapkit-with-swiftui import SwiftUI import MapKit struct Location: Identifiable {     let id = UUID()     let name: String     let coordinate: CLLocationCoordinate2D } struct ContentView: View {     @State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.5, longitude: -0.12), span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2))     let locations = [         Location(name: "Buckingham Palace", coordinate: CLLocationCoordinate2D(latitude: 51.501, longitude: -0.141)),         Location(name: "Tower of London", coordinate: CLLocationCoordinate2D(latitude: 51.508, longitude: -0.076))     ]     var body: some View {         Map(coordinateRegion: $region, annotationItems: locations) { location in             MapAnnotation(coordinate: location.coordinate) {                 Circle()                     .stroke(.red, lineWidth: 3)                     .frame(width: 44, height: 44)             }         }         .navigationTitle("Map")         .edgesIgnoringSafeArea(.all)     } }
Posted
by
Post not yet marked as solved
2 Replies
1.8k Views
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
Posted
by
Post not yet marked as solved
7 Replies
2.0k Views
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
Posted
by
Post not yet marked as solved
6 Replies
1.2k Views
Since iOS 16.3, our app users have reported that while their devices are in Airplane Mode, all MKOverlays on our MapView will simply vanish from the view. The overlays are rendered using locally stored data, so network connection isn't an issue. Also, if the users turn off Airplane Mode and still have no internet connection, the overlays will reappear as normal (although the phone will be searching for a cellular network when the user prefers otherwise). We had hoped the update to 16.4 would solve the problem, since it mentioned fixes for MKOverlays, but so far it has persisted. We've sent a report through Feedback Assistant and a TSI request, but both have gone unanswered by Apple. Anyone have other ideas?
Posted
by
Post not yet marked as solved
4 Replies
1.1k Views
Hi, I updated Xcode to version 14.3 (14E222b) which comes with iOS 16.4 Also macOS has the latest update Ventura 13.3 (22E252) Mac hardware is a MacBook Pro M1 Max After the update in MapKit (Not SwiftUI) MKPolylineRenderer won't render any more in an iOS 16.4 emulator (but still works fine on a physical device). In the terminal I see many lines like this: "Compiler failed to build request" "PSO error: reading from a rendertarget is not supported" I don't see these lines on a physical device and the polylines render fine on a physical device. Has anybody else seen this? Anything I can do? Thanks Gerd P.S. workaround: works for me when I choose the target "My Mac (Designed for iPad)"
Posted
by
Post not yet marked as solved
2 Replies
1.4k Views
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?
Posted
by
Post not yet marked as solved
2 Replies
1.6k Views
Hi, when I add mapview to my viewcontroller i receive the log [Pipeline Library] Mapping the pipeline data cache failed, errno22. This happened after i had updated xcode to 14.3 and the log is only shown when i test on a real device and not when i test on the simulator. (This is shown always in every project i create, even without calling any function to modify the mapview. I only add the MapKit and Core Location libraries.) Xcode version: Version 14.3 (14E222b) Iphone: Iphone 8, IOS version: 16.4 I've tested also on Iphone 12 with lower IOS version and i receive the same error.
Posted
by
Post not yet marked as solved
2 Replies
782 Views
According to the MKMapview, all annotations should be added to the map: https://developer.apple.com/documentation/mapkit/mkmapview When configuring your map interface, be sure to add all of your annotation objects right away. The map view uses the coordinate data in each annotation object to determine when the corresponding annotation view needs to appear onscreen. When an annotation moves onscreen, the map view asks its delegate to create a corresponding annotation view. If your app has different types of annotations, it can define different annotation view classes to represent each type. But this has a very low performance when the map is zoomed out and all annotations are visible (although market already filters out most of the annotations and only displays a few). As fas as I've seen, the suggestion from the documentation doesn't scale properly when the number of annotations is very large. Grouping doesn't help, neither using reusable annotations. Is the only option here, handling manually the add/remove annotations as the map rect changes?
Posted
by
Post not yet marked as solved
0 Replies
966 Views
I have an angular 13 leaflet application that can display OpenStreetMap, google, bing and apple maps. I have a function which uses DomToImage.toPng to generate an image of the currently displayed map. This works as expected with OpenStreetMap, google and bing. However, with apple maps, the maps are rendered as a solid grey. There are no exceptions shown in the console as one might expect from a tainted canvas. Loading the map: if ( this.appleMapsApiKey !== 'n/a' ) { ml.layer = (L as any).mapkitMutant ({ type: 'hybrid', // valid 'type' are 'standard', 'satellite', 'hybrid', 'muted' authorizationCallback: function(done) { // console.log ( 'Apple Maps Authorization Callback with ' + outerThis.appleMapsApiKey ); done ( outerThis.appleMapsApiKey ); }, language: 'en', attribution: '© ' + ml.name, debugRectangle: false, opacity: 1, minzoom: 3, maxzoom: 23 }); } Saving the map as a .png this.swlDataUrl = null; const node = document.getElementById('map'); if ( node != null ) { const container = this.map.getContainer(); const options = { width: container.clientWidth, height: container.clientHeight }; try { const dataUrl = await domToImage.toPng(node, options); if ( dataUrl != null ) { this.swlDataUrl = dataUrl; } return this.swlDataUrl; } catch (error) { console.error('ERROR: swlGetMapViewDomToImageInt error ' + error); } } else { console.error ( 'ERROR: swlGetMapViewDomToImageInt - no document node with id "map"' ); } Any ideas?
Posted
by
Post not yet marked as solved
3 Replies
1k Views
Hello Team, We have Advanced App Clip Experiences live but we have add App Clip experience URL since long ago but status remains as Received and never changed to Published, can you please help us to fix this issue. Please see attached. Thanks
Posted
by
Post not yet marked as solved
0 Replies
395 Views
Hi everyone, I'm basically trying to copy Apple Maps for learning purposes. I've added the map but with Mapbox. I've also created UISheetPresentationController on top of this map but the map is not responding my touches. What variables do I need to override or activate to be able to interact with map and buttons on it?
Posted
by