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

124 Posts
Sort by:
Post not yet marked as solved
2 Replies
779 Views
Togther with MKMapSnapshotter, Mapkit provides all the tools to create animations, respectively image sequences.For example:https://youtu.be/yub8oVTA2fwFor this example the heading property of the mkMapCamera was animated. The movementof the camera looks smooth. (That's fine)In the next example the MKMapView.centerCoordinate was animated.https://youtu.be/QY7Pmg5oE2MYou may have noticed the jumps during the movement of the camera. (That's bad)The MKMapView.camera gets automatic updates.(Animation of the MKMapCamera.centercoordinate directlyhas the same effect) The jumps may rely on the MKMapCamera.altitude property. Because every change in centercoordinate the altitude of the camera is also updated.Altitude is defined as meters above ground and consequently the camera seems to follow the mapssurface. Interestingly, if the animation is made with mapkits own animator, it ispossible to move from A to B without height-changes.https://youtu.be/x7SzU20BJPM(The example was made with a NSView-Screencapture)Unfortunately the snapshotter cannot be used to get the frames because the camera is updated during snapshot-options preparation. This causes (?)also a correction (or reset) of the altitude property and thus the jump in the animation.So here is my question/suggestion.Would it be nice to have a MKMapCamera.aboveMeanSeaLevel property?Is there a workaround to get a moving camera in altitude above sea-level, i.esuppressing the altitude update?Thanks for any suggestions!
Posted
by
Post not yet marked as solved
13 Replies
6.5k Views
After spending two hours trying to find anything on it (and failing), I hope for a last resort here: I have a very simple map with annotation markers. Problem: the user taps on a marker or pin — and in the past it used to fire a "didSelect" on the mapView, but now?! How do I react to the user tapping a pin or marker? I tried to add a .onTapGesture but no such thing. Map(   coordinateRegion: $viewMapModel.mapLocation,   annotationItems: viewMapModel.annotations,   annotationContent: { 		n in MapMarker( 			coordinate: n.location, 			tint: .red 		) 	} ) Essentially, once a user taps a pin or marker, I want to show a popup, but just showing a print would already make my world for simplicity purposes here. I want to use this new iOS 14+ format, so please no solutions taking me back to makeUIView->MKMapView stuff. Thanks!
Posted
by
Post marked as solved
6 Replies
1.5k Views
Greetings, I'm attempting to refactor a SwiftUI application. From: IUViewRepresentable of MapView To: SwiftUI's native Map() view. However my application has to be able to react to the user's panning and zooming. In my UIViewRepresentable version, I added MKMapViewDelagate protocol to the Coordinator class, and create mapView(_ mapView:regionDidChangeAnimated) How can assign a delegate class to the SwiftUI native version to accomplish this? I've seen some posts use an init() method to adjust the appearance of the map with MKMapView.appearance(). Turns out this has a delegate property, but assigning a delegate here does not result in the mapView:regionDidChangeAnimated method being called...
Posted
by
Post not yet marked as solved
3 Replies
1.5k 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
10 Replies
1.7k Views
I need to remove a Polyline and replace it by a new one on my mapView about every 2 seconds. The Polyline is correctly removed and added to the screen so that is great. But I see the app memory use increase by about 5 mb per minute. This results in the app becoming very slow and unresponsive. I see the problem on the IOS 14.2 simulator and hardware (iPhone and iPad). On my 13.4 simulator this problem does occur and all works fine without memory leaking. Below run the the steps to reproduce in a loop: 1 create a regular polyLine with about 50 entries polyLine.title = "polyLine" 2 mapView.addOverlay(PolyLine) 3 let allOverlays = mapView.overlays for overlay in allOverlays { if (overlay.title == "polyLine") {     mapView.removeOverlay(overlay)   } } 4 mapView.addOverlay(PolyLine) Note: I see the same problem when navigation routes (that is also using Polyline overlay) are recreated. So it looks like MapView graphically works ok but is not releasing memory after mapView.removeOverlay(overlay) is called. Here is some output from instruments/leaks pointing to VectorKit: MTLSimTexture 4048 < multiple > 1,48 MiB MTLSimDriver _77-[MTLSimTexture newTextureViewWithPixelFormatInternal:isInternalTextureView:]block_invoke Malloc 16 Bytes 4083 < multiple > 63,80 KiB VectorKit geo::MallocZoneAllocator::allocate(unsigned long, unsigned long) Malloc 144 Bytes 4105 < multiple > 577,27 KiB VectorKit geo::MallocZoneAllocator::allocate(unsigned long, unsigned long)
Posted
by
Post not yet marked as solved
5 Replies
1k Views
I have an standard Open Street Map Overlay implemented. It works perfect on the Simulator and when I set explicitly canReplaceMapContent to YES on the overlay. If I set it to NO, it will not display on any iOS 14 device. iOS 13 devices were able to display it. I develop the app in Objective C, the overlay was working for many iOS releases before. Standard MKTileOverlay, standard URL tile.openstreetmap.org: &#9;_tileOverlay = [[MKTileOverlay alloc] initWithURLTemplate:@"https://<OSM URL>/{z}/{x}/{y}.png"]; &#9;_tileOverlay.canReplaceMapContent = NO; &#9;[_mapView addOverlay:_tileOverlay level:MKOverlayLevelAboveLabels]; Standard MKTileOverlayRenderer: (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay { &#9;if ([overlay isKindOfClass:[MKTileOverlay class]]) { &#9;&#9;return [[MKTileOverlayRenderer alloc] initWithOverlay:overlay]; &#9;} Having to set canReplaceMapContent to YES on the tile overlay leads to some flickering, which would be easy to avoid setting it to NO, but setting NO leads to only grey tiles, resp. no tiles drawn at all. Any ideas?
Post not yet marked as solved
2 Replies
1.7k Views
I already know how to set up map pins or annotations like discussed here: https://developer.apple.com/forums/thread/651668 But the real question is: How do I replace the hardcoded location data with passed parameters? This Code is executed without problems, due to the fact that the coords in locations are hardcoded: import MapKit struct Location: Identifiable {     let id = UUID()     let name: String     let latitude: Double     let longitude: Double     var coordinate: CLLocationCoordinate2D {         CLLocationCoordinate2D(latitude: latitude, longitude: longitude)     } } struct MapView: View {     let locations = [Location(name: "Turtle Rock", latitude: 34.011_286, longitude: -116.166_868)]     var coordinate: CLLocationCoordinate2D     var lat: Double     var long: Double     @State private var region = MKCoordinateRegion()     var body: some View {         Map(coordinateRegion: $region,showsUserLocation: true, annotationItems: locations){ loco in             MapPin(coordinate: loco.coordinate)         }         .onAppear{             setRegion(coordinate)         }   .edgesIgnoringSafeArea(.all)     }     private func setRegion(_ coordinate: CLLocationCoordinate2D){         region = MKCoordinateRegion(             center: coordinate,             span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2)         )     } } struct MapView_Previews: PreviewProvider {     static var previews: some View {         MapView(coordinate: CLLocationCoordinate2D(latitude: 34.011_286, longitude: -116.166_868),lat: 34.011_286, long: -116.166_868)     } } But as soon as I try to use lat(itude) or long(itude) or even coordinate from the passed parameters, I have to use lazy vars and therefore cannot access that mutable getters... any advice? let locations = [Location(name: "Turtle Rock", latitude: lat, longitude: long)] //this Throws: Cannot use instance member 'lat' within property initializer; property initializers run before 'self' is available. //Using lazy var results in: Cannot use mutating getter on immutable value: 'self' is immutable
Posted
by
Post not yet marked as solved
5 Replies
1.5k 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
3 Replies
1.3k Views
MKLocalSearch.start - https://developer.apple.com/documentation/mapkit/mklocalsearch/1452652-start is giving me MKErrorGEOError=-8 which is not documented in MKError - https://developer.apple.com/documentation/mapkit/mkerror. This only happens in my CI machine! This only happens when running the tests, the app code works fine I tried enabling location services on macOS just in case, but it didn't work. That machine shouldn't have any network requests/URLs blocked What fixed for me was to add request.naturalLanguageQuery = "Venue", but I don't understand why, nor why this would fix an error that is happening in only 1 machine. Does anyone have any information about this? Here's some sample code: let request = MKLocalSearch.Request() request.naturalLanguageQuery = "Venue" // this fixes it, but why?! let ibereCamargoMuseumCoordinates = CLLocationCoordinate2D(latitude: -30.0777596, longitude: -51.2477212) let span = MKCoordinateSpan(latitudeDelta: 5, longitudeDelta: 5) request.region = MKCoordinateRegion(center: ibereCamargoMuseumCoordinates, span: span) if #available(iOS 13.0, *) { request.resultTypes = .pointOfInterest } let localSearch = MKLocalSearch(request: request) localSearch.start { response, error in ... } Here's some debugging output: (lldb) po error Error Domain=MKErrorDomain Code=4 "(null)" UserInfo={MKErrorGEOError=-8} (lldb) po error.userInfo ▿ 1 element ▿ 0 : 2 elements ▿ key : AnyHashable("MKErrorGEOError") - value : "MKErrorGEOError" value : -8 If you're interested I asked this on Stack Overflow - https://stackoverflow.com/questions/66976777/mklocalsearch-start-returning-undocumented-mkerrorgeoerror too.
Posted
by
Post not yet marked as solved
3 Replies
889 Views
Hi I am developing an app with swiftUI. Here is the code of a map view. I create customized annotations and show them on the map view. The issue is that when I drag or zoom in/ out on the map view. The app is so slow. The fps decrease to about 20 - 30 from 60. I use instruments to analyze this app. The result shows that there are thousands of times annotation render. I think that the reason for this issue may be off-screen rendering. But I don't know how to solve it. Looking forward to your help. swift Map(coordinateRegion: $region, interactionModes: .all, showsUserLocation: true, userTrackingMode: $trackingMode, annotationItems: result, annotationContent: { mark in MapAnnotation(coordinate: CLLocationCoordinate2D(latitude: mark.lat, longitude: mark.long)) {   Button {withAnimation { self.selectedGymUid = Int(mark.uid) }} label: {RoundedGymIconOnMapView(name:mark.name) .clipShape(Circle()) .overlay(Circle().stroke(selectedGymUid == Int(mark.uid) ? Color(.green).opacity(0.5) : AppColor.shared.joggingColor.opacity(0.5),lineWidth: 1.4)) .scaleEffect(selectedGymUid == Int(mark.uid) ? 2 : 1) .shadow(radius: 5) } } })
Posted
by
Post not yet marked as solved
0 Replies
769 Views
My app is crashing and I suspect it is from MKMapView I am using an MKMapView in my application. I want to link the user to Apple Maps. The user may want to use Apple Maps, so I allow them to click a button, and when tapped it calls the following:      var url = URLComponents(string: "https://maps.apple.com")     let queryItems = URLQueryItem(name: "q", value: place.name)     url?.queryItems = [queryItems]          UIApplication.shared.open(url!.url!.absoluteURL) Approximately 80% of the time I call this, I am seeing a crash: libc++abi: terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument This is the stack trace Thread 1 Queue : com.apple.main-thread (serial) #0 0x00000001be057734 in __semwait_signal () #1 0x00000001993dba34 in nanosleep () #2 0x00000001993db8f8 in usleep () #3 0x00000001932cb684 in CABackingStoreCollectBlocking () #4 0x0000000192cc0ab0 in __35-[UIWindowScene _prepareForSuspend]_block_invoke () #5 0x000000019208c7cc in -[_UIContextBinder purgeContextsWithPurgeAction:] () #6 0x0000000192cc0a38 in -[UIWindowScene _prepareForSuspend] () #7 0x0000000191ec6490 in -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] () #8 0x0000000191ec74c8 in -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] () #9 0x0000000192537b5c in -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] () #10 0x000000019f5baeb8 in -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] () #11 0x000000019f5e74f0 in __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 () #12 0x000000019f5c96a4 in -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] () #13 0x000000019f5e741c in __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke () #14 0x0000000101105d90 in _dispatch_client_callout () #15 0x000000010110981c in _dispatch_block_invoke_direct () #16 0x000000019f60dfa0 in __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ () #17 0x000000019f60dc30 in -[FBSSerialQueue _targetQueue_performNextIfPossible] () #18 0x000000019f60e184 in -[FBSSerialQueue _performNextFromRunLoopSource] () #19 0x000000018ffd8848 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ () #20 0x000000018ffd8744 in __CFRunLoopDoSource0 () #21 0x000000018ffd7a48 in __CFRunLoopDoSources0 () #22 0x000000018ffd1a28 in __CFRunLoopRun () #23 0x000000018ffd11c0 in CFRunLoopRunSpecific () #24 0x00000001a75b9734 in GSEventRunModal () #25 0x0000000192a3f7e4 in -[UIApplication _run] () #26 0x0000000192a45054 in UIApplicationMain () #27 0x000000010095d2f8 in main at /Users/ZXX/Developer/ZXZZ/AppLogic/AppDelegate.swift:14 #28 0x000000018fc8dcf8 in start () Thread 3#0 0x00000001dba81744 in start_wqthread () com.apple.uikit.eventfetch-thread (5)#0 0x00000001be0324fc in mach_msg_trap () #1 0x00000001be031884 in mach_msg () #2 0x000000018ffd7d10 in __CFRunLoopServiceMachPort () #3 0x000000018ffd1bb0 in __CFRunLoopRun () #4 0x000000018ffd11c0 in CFRunLoopRunSpecific () #5 0x00000001912b1fac in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] () #6 0x00000001912b1e78 in -[NSRunLoop(NSRunLoop) runUntilDate:] () #7 0x0000000192af438c in -[UIEventFetcher threadMain] () #8 0x00000001914232fc in __NSThread__start__ () #9 0x00000001dba78c00 in _pthread_start () Thread 6#0 0x00000001dba81744 in start_wqthread () Thread 11#0 0x00000001dba81744 in start_wqthread () com.apple.NSURLConnectionLoader (12)#0 0x00000001be0324fc in mach_msg_trap () #1 0x00000001be031884 in mach_msg () #2 0x000000018ffd7d10 in __CFRunLoopServiceMachPort () #3 0x000000018ffd1bb0 in __CFRunLoopRun () #4 0x000000018ffd11c0 in CFRunLoopRunSpecific () #5 0x00000001908aa4b8 in ___lldb_unnamed_symbol11592$$CFNetwork () #6 0x00000001914232fc in __NSThread__start__ () #7 0x00000001dba78c00 in _pthread_start () Thread 14#0 0x00000001dba81744 in start_wqthread () AVAudioSession Notify Thread (15)#0 0x00000001be0324fc in mach_msg_trap () #1 0x00000001be031884 in mach_msg () #2 0x000000018ffd7d10 in __CFRunLoopServiceMachPort () #3 0x000000018ffd1bb0 in __CFRunLoopRun () #4 0x000000018ffd11c0 in CFRunLoopRunSpecific () #5 0x0000000197a4df20 in GenericRunLoopThread::Entry(void*) () #6 0x0000000197a500d8 in CAPThread::Entry(CAPThread*) () #7 0x00000001dba78c00 in _pthread_start () Thread 16#0 0x00000001dba81744 in start_wqthread () Thread 17#0 0x00000001dba81744 in start_wqthread () Thread 18 Queue : com.Metal.CompletionQueueDispatch (serial) #0 0x00000001be057334 in __pthread_kill () #1 0x00000001dba79aa0 in pthread_kill () #2 0x00000001993deb90 in abort () #3 0x00000001a4bbebb8 in abort_message () #4 0x00000001a4bafeb0 in demangling_terminate_handler() () #5 0x00000001a4abc06c in _objc_terminate() () #6 0x00000001a4bbdfa0 in std::__terminate(void (*)()) () #7 0x00000001a4bbdf2c in std::terminate() () #8 0x00000001a4add91c in objc_terminate () #9 0x0000000101105e70 in _dispatch_client_callout4 () #10 0x0000000101123318 in _dispatch_mach_msg_invoke () #11 0x000000010110dcbc in _dispatch_lane_serial_drain () #12 0x000000010112431c in _dispatch_mach_invoke () #13 0x000000010110dcbc in _dispatch_lane_serial_drain () #14 0x000000010110ecf8 in _dispatch_lane_invoke () #15 0x000000010110dcbc in _dispatch_lane_serial_drain () #16 0x000000010110ecc4 in _dispatch_lane_invoke () #17 0x000000010111ba00 in _dispatch_workloop_worker_thread () #18 0x00000001dba7a7a4 in _pthread_wqthread ()
Posted
by
Post not yet marked as solved
11 Replies
3.0k 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
319 Views
I would like to create an app that shows the direction you are facing even after scrolling, like the stock Apple map. However, when I use MKusertracking to display the heading, the heading is hidden after scrolling. How can I solve this problem?
Posted
by
Post not yet marked as solved
1 Replies
909 Views
since I set the MKUserTrackingMode to follow I get this error : [MKCoreLocationProvider] CLLocationManager(<CLLocationManager: 0x6000003b86d0>) for <MKCoreLocationProvider: 0x6000033b05a0> did fail with error: Error Domain=kCLErrorDomain Code=1 "(null)" and the map doesn't track the location of the gpx file either. What can you do there?
Posted
by
Post not yet marked as solved
0 Replies
418 Views
I am using MapKit to show navigation directions between source and destination location like in apple and google maps. With the help of MKRoute object, i am showing distance required for the user to make his next turn in x distance. For distance i'm using the below method. Eg: Take Right(route.step.instructions) 0.8 mi (route.step.distance)     for monitoredRegions in locationManager.monitoredRegions {       locationManager.stopMonitoring(for: monitoredRegions)     }     let steps = route.steps     self.steps = steps     for i in 0 ..< steps.count {       let step = steps[i]       print(step.instructions)       print(step.distance)       let region = CLCircularRegion(center: step.polyline.coordinate,                      radius: 20, identifier: "\(i)")       locationManager.startMonitoring(for: region)     }     stepCounter += 1     let directionText = steps[stepCounter].instructions     self.titleLabel.text = directionText     self.distanceLabel.text = "\(steps[stepCounter].distance)"   } I want to change the distance as user navigates closer to the take the right turn, and minimise the distance from 0.8 to 0.0 and update it continuously in real time. Kindly check the image and let me know a simple way to achieve it.
Posted
by
Post not yet marked as solved
1 Replies
300 Views
Hi,  I am relatively new to Swift/SwiftUI/MapKit. How would you display map annotations in SwiftUI - with JSON containing Eastings and Northings (X and Y co-ordinates) rather than Latitudes and Longitudes? {   "header" : {    "uri" : "https://api.os.uk/search/places/v1/uprn?uprn=200010019924",    "query" : "uprn=200010019924",    "offset" : 0,    "totalresults" : 1,    "format" : "JSON",    "dataset" : "DPA",    "lr" : "EN,CY",    "maxresults" : 100,    "epoch" : "86",    "output_srs" : "EPSG:27700"   },   "results" : [ {    "DPA" : {     "UPRN" : "200010019924",     "UDPRN" : "52126562",     "ADDRESS" : "ORDNANCE SURVEY, 4, ADANAC DRIVE, NURSLING, SOUTHAMPTON, SO16 0AS",     "ORGANISATION_NAME" : "ORDNANCE SURVEY",     "BUILDING_NUMBER" : "4",     "THOROUGHFARE_NAME" : "ADANAC DRIVE",     "DEPENDENT_LOCALITY" : "NURSLING",     "POST_TOWN" : "SOUTHAMPTON",     "POSTCODE" : "SO16 0AS",     "RPC" : "2",     "X_COORDINATE" : 437292.43,     "Y_COORDINATE" : 115541.95,     "STATUS" : "APPROVED",     "LOGICAL_STATUS_CODE" : "1",     "CLASSIFICATION_CODE" : "CO01GV",     "CLASSIFICATION_CODE_DESCRIPTION" : "Central Government Service",     "LOCAL_CUSTODIAN_CODE" : 1760,     "LOCAL_CUSTODIAN_CODE_DESCRIPTION" : "TEST VALLEY",     "POSTAL_ADDRESS_CODE" : "D",     "POSTAL_ADDRESS_CODE_DESCRIPTION" : "A record which is linked to PAF",     "BLPU_STATE_CODE" : "2",     "BLPU_STATE_CODE_DESCRIPTION" : "In use",     "TOPOGRAPHY_LAYER_TOID" : "osgb1000002682081995",     "LAST_UPDATE_DATE" : "31/03/2020",     "ENTRY_DATE" : "01/09/2010",     "BLPU_STATE_DATE" : "01/09/2010",     "LANGUAGE" : "EN",     "MATCH" : 1.0,     "MATCH_DESCRIPTION" : "EXACT"    }   } ] } Thanks
Posted
by
Post not yet marked as solved
0 Replies
322 Views
Hi, I have to build an app that allow my colleagues to see each others current position by checking a map (let's skip that "find my" works really well for this). Since we have different offices around the city, it must give us the chance to look for a specific address and see who of our colleagues are close to that location. I can find a way to code this but how do I have to structure the project? I mean start/end task in general terms.. It would be a tremendous help Thanks Andres
Posted
by