In UIKit, we can add an insets to a MKMapView with setVisibleMapRect to have additional space around a specified MKMapRect. It's useful for UIs like Apple Maps or FlightyApp (see first screenshot attached). This means we can have a modal sheet above the map but still can see all the content added to the map.
I'm trying to do the same for a SwiftUI Map (on iOS 17) but I can't find a way to do it: see screenshot 2 below. Is it possible to obtain the same result or should I file a feedback for an improvement?
Maps and Location
RSS for tagBuild maps and location awareness capabilities into your apps.
Posts under Maps and Location tag
84 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Am looking to finally updating some old code now that we are dropping iOS 15 support and want to move to the new mkMapView configurations such as MKHybridMapConfiguration.
However when I use that configuration I cannot get it to show traffic conditions, even though I am setting showsTraffic = true
Bug, feature, dumb coding error on my part?
Hey yall--seemingly once in a blue moon whenever fetchLocation gets called in here from a widget that is requesting location, it calls on the manager's requestLocation, the widget will crash. Crash stack backtrace shows this:
And this is the affected code:
import Foundation
import CoreLocation
class WidgetLocationFetcher: NSObject, CLLocationManagerDelegate {
let manager = CLLocationManager()
private var handler: ((CLLocation?) -> Void)?
override init() {
super.init()
DispatchQueue.main.async {
self.manager.delegate = self
self.manager.requestWhenInUseAuthorization()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
self.handler?(locations.last!)
self.handler = nil
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error)
self.handler?(nil)
self.handler = nil
}
func fetchLocation(handler: @escaping (CLLocation?) -> Void) {
self.handler = handler
self.manager.requestLocation()
}
}
I am not too sure what could even be causing this, although I am running watchOS 10 beta 8 and iPadOS 17 beta 8 on the devices experiencing this crash. Has anyone ever solved this issue?
MacBook cannot detect my location. Google Maps, HorizonBlue, and others tell me to enable location services. Everything seems to be enabled but the problem persists. Started around a month ago.
TRIED: Resetting the MacBook, Shut down, Restart, Clear cookies
VERSION: Sonoma Beta 14.0 (23A5301h)
We are currently experiencing a very interesting issue when accessing the location in the background with CLLocationManager.
The user has given our app the "whenInUse" permission for locations and in most cases the app provides location updates even when it's in the background.
However, when we started to use other navigation apps in the foreground we saw that the func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) method was called with (kCLErrorDomain error 1.).
The user hasn't changed the location permission and we saw that locations were delivered once the user opened the app again.
I don't see anything in the documentation explaining this issue, but I chatted with other developers that confirm that specific behavior.
Am I missing something here?
I'm looking to integrate Apple Maps features into my WordPress website for location-based content. Has anyone successfully accomplished this and can share insights on how to seamlessly incorporate interactive maps within the WordPress platform? Any recommended plugins, APIs, or coding approaches that ensure a smooth integration and optimal user experience across devices? I'd greatly appreciate any guidance on best practices, potential challenges to watch out for, and practical tips based on your experiences. Thank you!
Hi,
We've released a golf app available on iOS.
It uses MapKit to display maps : golfcourses, shots, livecaddie, telemeter etc.
Some users from South-Korea are complaining about not being able to zoom-in on areas located in their country (particularly in the New Seoul Country Club).
They can have an overview of the golfcourse but it's impossible to get closer.
If they try on other golfcourses located in the US or in the UK, it works perfectly (still trying from Korea).
We can't replicate the issue on the Simulator.
We changed the language/region + gps location to South-Korean.
Our IP is located in France.
Do you know if there's some restriction about map display depending on the country you are currently located?
Me encuentro en el país de Colombia y por muchos años todavía Apple no va habilitado el modo de navegación en mi país también me di cuenta que hay muchos países con ciudades muy importantes claro está que tienen sus ciudades muy bonitas en mapas 3D fotorealismo o en mapas 3D en vista estándar mi pregunta es si yo desde Colombia desde mi ciudad podría ayudar a qué las fotos del terreno visto desde el aire fueran mucho mejor con ayuda de un drone. Y así empezar a evolucionar un poco mi ciudad referente a Apple Maps, O también para empezar a que la navegación en Apple Maps sea más cercana de lo que Apple tiene pensado para nosotros
I'm using mapKit in swiftUI project and I want to remove administrative geometry and countries name.
Hi,
I'm looking through SwiftUI Map for SwiftUI documentation (including IOS17 Beta) for way to adjust Map() scale, or zoom level, while simultaneously showing user's location and heading, for which I'm doing this
@State var position = MapCameraPosition = .userLocation(followsHeading: true, fallback: .automatic)
Map(position: $position)
It does not appear to be possible so am looking for confirmation. Thanks everyone.
Hello, we are currently working with a third-party mapping company and they are saying due to Apple's management, the Indoor maps Programm is currently not accepting any third-party IMDF files. Can you confirm if this is true? How can we then publish the file?
Thank you in advance
when requestWhenInUseAuthorization() some phone not show system prompt view,The NSLocationWhenInUseUsageDescription key is already add.
-locationManager:didChangeAuthorizationStatus: callback too kCLAuthorizationStatusNotDetermined,but the iPhone not show use location dialog,Does anyone know the reason?
Getting the crash only in iOS 14.x and i cannot identify the reason.
Log:
Crashed: com.apple.main-thread
0 VectorKit 0x324360 md::FrameGraphUtils::prepareGraphBuilderForRenderTarget(md::FrameGraphBuilder*, ggl::RenderTarget*, geo::StringLiteral, geo::StringLiteral, geo::StringLiteral) + 72
1 VectorKit 0x526f20 md::PassList::didPrepareForLayout(md::LayoutContext const&, md::Renderer&) + 276
2 VectorKit 0x526f20 md::PassList::didPrepareForLayout(md::LayoutContext const&, md::Renderer&) + 276
3 VectorKit 0x99dc4 md::CartographicRenderer::layout(md::LayoutContext&) + 120
4 VectorKit 0x8e2ac md::MapEngine::layoutScene(double, bool) + 664
5 VectorKit 0x8de5c -[_MapEngineRenderQueueSource renderQueueForTimestamp:] + 60
6 VectorKit 0x8ddf4 -[MDDisplayLayer _renderQueueForTimestamp:prepareHandler:] + 36
7 VectorKit 0x8ddc0 -[MDDisplayLayer renderQueueForTimestamp:] + 48
8 VectorKit 0x8d028 -[MetalLayer _onTimerFired:withPresent:] + 256
9 VectorKit 0x8c7b4 md::MapEngine::renderScene(double, std::__1::function<void ()>) + 100
10 VectorKit 0xca7a8 md::MapEngine::onRenderTimerFired(double) + 344
11 VectorKit 0x4ab388 std::__1::function<void (double)>::operator()(double) const + 48
12 VectorKit 0xca594 ggl::RunLoop::_RunLoopCallbacker::callback(double) + 144
13 VectorKit 0x63c2b8 ___ZN3ggl11DisplayLinkC2ENSt3__18functionIFvdEEE_block_invoke_2 + 92
14 libdispatch.dylib 0x4420 _dispatch_client_callout + 20
15 libdispatch.dylib 0x779c _dispatch_continuation_pop + 416
16 libdispatch.dylib 0x19298 _dispatch_source_invoke + 1260
17 libdispatch.dylib 0x11d04 _dispatch_main_queue_callback_4CF + 556
18 CoreFoundation 0xc39ec CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16
19 CoreFoundation 0x82878 __CFRunLoopRun + 2508
20 CoreFoundation 0x81740 CFRunLoopRunSpecific + 600
21 HIToolbox 0x315c4 RunCurrentEventLoopInMode + 292
22 HIToolbox 0x313f4 ReceiveNextEventCommon + 688
23 HIToolbox 0x31124 _BlockUntilNextEventMatchingListInModeWithFilter + 76
24 AppKit 0x4182c _DPSNextEvent + 868
25 AppKit 0x401ac -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1312
26 AppKit 0x32060 -[NSApplication run] + 600
27 AppKit 0x3804 NSApplicationMain + 1064
28 AppKit 0x2f56d4 _NSApplicationMainWithInfoDictionary + 22
29 UIKitMacHelper 0x4fc4 UINSApplicationMain + 1276
30 UIKitCore 0x2a60 UIApplicationMain + 164
31 libswiftUIKit.dylib 0x13688 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 104
32 BilliyoClinicalPDN 0x1b898 main + 4377884824 (GoalProgressHeader.swift:4377884824)
33 libdyld.dylib 0x16f34 start + 4
Thread
0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352
2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8
Thread
0 libsystem_pthread.dylib 0x1d8c qos_class_main + 98
Thread
0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352
2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8
Thread
0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352
2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8
com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0xce8 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1098 mach_msg + 76
2 CoreFoundation 0x83e98 __CFRunLoopServiceMachPort + 380
3 CoreFoundation 0x8236c __CFRunLoopRun + 1216
4 CoreFoundation 0x81740 CFRunLoopRunSpecific + 600
5 Foundation 0x64a88 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232
6 Foundation 0xf3254 -[NSRunLoop(NSRunLoop) runUntilDate:] + 124
7 UIKitCore 0x3ff4 -[UIEventFetcher threadMain] + 156
8 Foundation 0x5d0f4 NSThread__start + 864
9 libsystem_pthread.dylib 0x706c _pthread_start + 320
10 libsystem_pthread.dylib 0x1da0 thread_start + 8
Thread
0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352
2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8
Thread
0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352
2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8
Thread
0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352
2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8
Thread
0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352
2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8
Thread
0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352
2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8
com.google.firebase.crashlytics.MachExceptionServer
0 FirebaseCrashlytics 0x1ef98 FIRCLSProcessRecordAllThreads + 184
1 FirebaseCrashlytics 0x1f378 FIRCLSProcessRecordAllThreads + 1176
2 FirebaseCrashlytics 0x16618 FIRCLSHandler + 48
3 FirebaseCrashlytics 0x18dd8 FIRCLSMachExceptionServer + 688
4 libsystem_pthread.dylib 0x706c _pthread_start + 320
5 libsystem_pthread.dylib 0x1da0 thread_start + 8
com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0xce8 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1098 mach_msg + 76
2 CoreFoundation 0x83e98 __CFRunLoopServiceMachPort + 380
3 CoreFoundation 0x8236c __CFRunLoopRun + 1216
4 CoreFoundation 0x81740 CFRunLoopRunSpecific + 600
5 CFNetwork 0x24c7d0 _CFURLStorageSessionCopyCache + 36132
6 Foundation 0x5d0f4 NSThread__start + 864
7 libsystem_pthread.dylib 0x706c _pthread_start + 320
8 libsystem_pthread.dylib 0x1da0 thread_start + 8
Request users' permissions to have their location displayed on a map; users must have the option to decline this request
Require users to manually check-in each time they wish to have their location displayed on a map; there should be no option to enable automatic check-ins
A feature of my app I am in need of is to allow users to go through their room and mark specific positions, then be able to navigate these positions with a floor plan like a map. Think google maps but for your room, showing the user's position.
I know it is possible to make a floor plan with RoomPlan, which could act as a map, but would it be possible after the plan is made to track a user's location in the room and show it?
Is this too complex for RoomPlan? And if so how would I tackle this problem?
Hey guys,
I recently started using Swiftui and would like to make a small app for my dad to use as a travel journal as my first project.
He can create trips and then create multiple steps in a trip. When creating a step he should be able to set a location.
Finding the location from the user is no problem. But now I also want to have the function to tap on the map and set a pin at a random location to get the coordinates (like google maps for example).
Unfortunately I can't figure out from the documentation if there is a simple way to do this.
import SwiftUI
import MapKit
struct StepLocationView: View {
@EnvironmentObject var locationManagement: LocationDataManager
@State private var position: MapCameraPosition = .automatic
var body: some View {
VStack {
Map(position: $position) {
UserAnnotation()
}
.navigationTitle("Search your location")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
.toolbarBackground(.ultraThinMaterial, for: .navigationBar)
.edgesIgnoringSafeArea(.bottom)
.onAppear{
position = .region(locationManagement.region)
}
.mapStyle(.standard(elevation: .realistic))
.mapControls {
MapUserLocationButton()
MapPitchButton()
}
}
.background(Color.white)
}
}
import SwiftUI
import MapKit
class LocationDataManager : NSObject, ObservableObject {
@Published var location: CLLocation?
@Published var region = MKCoordinateRegion()
private let locationManager = CLLocationManager()
override init() {
super.init()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = kCLDistanceFilterNone
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation() // info.plist has to be updated
locationManager.delegate = self
}
}
extension LocationDataManager: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let location = locations.last else { return }
self.location = location
self.region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude), latitudinalMeters: 5000, longitudinalMeters: 5000)
};
}
I really appreciate your help,
Marius
Hello,
I am currently working on an app for a client. The concept is straightforward: the app allows users to view the location of other users on a map, even when they are not actively using the app. However, this feature is limited to a selected group of people, specifically those who have joined the same group as the user.
To achieve this, I collect location data in the background. The primary objective of this app is to connect users with nearby individuals who can assist them with tasks or jobs.
However, I encountered an issue during the app review process. The review team deemed it inappropriate for deployment because it displays users' locations on a map, without the necessary privacy safeguards in place. Nevertheless, the main purpose of the app is to allow users to be visible on the map, and people who download the app intend to be included in this display.
Here is the comment provided by the reviewer:
Your app enables the display of nearby users' locations on a map, but does not have the required privacy precautions in place.
Additionally, here is the specific requirement:
Require users to manually check-in each time they wish to have their location displayed on a map; there should be no option to enable automatic check-ins.
If I understand correctly, this means that users would be required to open the app in order to appear on the map. However, this contradicts the purpose of the app, as users prefer to be passively visible without actively opening the app.
On the other hand, I have noticed tracking apps like Life360 and others that provide similar functionalities. They display users' locations on a map in near-real-time. What am I missing to ensure the validity of my app? The reviewer mentioned being unable to provide any hints, so I am hopeful that someone here can assist me.
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?
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)"
I have given location permission for the app i'm developing. Now i need to reset location permission and want to see the permission pop-up.
I have tried tccutil reset and /var/db/locationd/clients.plist is not accessible. Both are failing even with sudo.
Please suggest any methods.