Hello,
I'm trying to receive location updates on background mode but it only lasts about 10 minutes then it stops when API detected the "isStationary" is true.
Is there any way to continue receiving updates even when the device is stationary?
Btw app is not terminated by the user.
I'm using CLLocationUpdate.liveUpdates(.otherNavigation) API.
CLBackgroundActivitySession is created before calling the liveUpdates.
CLLocationManager:
let manager: CLLocationManager = {
let manager = CLLocationManager()
manager.distanceFilter = kCLDistanceFilterNone
manager.desiredAccuracy = kCLLocationAccuracyThreeKilometers
manager.pausesLocationUpdatesAutomatically = false
manager.activityType = .other
manager.showsBackgroundLocationIndicator = true
manager.allowsBackgroundLocationUpdates = true
return manager
}()
Thank you!
Maps & Location
RSS for tagLearn how to integrate MapKit and Core Location to unlock the power of location-based features in your app.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I cannot use maps and google maps, whenever connected to carplay, both gps position on the iphone and head unit becomes located in the middle of the sea.
My device is iphone 15 pro max, official ios 18.0
tested on two different iphones on ios 17 and ios 16 from the dealership, everything normal.
any same experience?
thanks
Hi fellow developers,
I'm encountering an issue when using MKLocalSearch to search for cities. Here's my setup:
I'm using MKLocalSearch with an MKLocalSearch.Request object.
I've set the resultTypes to .address to focus on address results.
The problem:
When I receive the search response, it includes the locations as expected. However, these locations don't have an identity or alternative identities.
Questions:
Is this the expected behavior when searching for cities?
Without an identity, how can I uniquely identify and store these city results in my database?
Would it be appropriate to store the city name, country, and coordinates instead?
Thanks in advance!
In my app, I need a one-time location update, which I do with CLLocationManager’s requestLocation().
On iOS, it works fine, but on macOS Sequoia, the CLLocationManagerDelegate’s didUpdateLocations function is called indefinitely in the loop, until I call stopUpdatingLocation() on a manager. This should not be necessary unless I was calling startUpdatingLocation (which I am not), and seems like a newly introduced bug in Sequoia (or Xcode 16).
So, just a heads-up to everyone, it's necessary to call stopUpdatingLocation() after obtaining the location (or on error).
Hello everyone -
I created a navigation app that uses a map overlay for finite spaces such as a zoo. I get these overlays created by a designer in .PNG - the designer creates the overlays and then puts a square or rectangle box around the overlay because it needs to be placed in 9 pieces making it easier to render when user zooms in/out...
I used to have my Swift devs place the overlay using the correct coordinates that were given by a single person, but we never found out exactly how they did it - and now I can no longer contact the dev.
Can anyone help me by telling me how I can get the coordinates (I am thinking that any opposite vertices would do - and maybe the center point?).
I also have a few other questions:
a. Is .SVG best to use for map overlays?
b. Should we continue to chop into 9 pieces for faster rendering or is there a better way to do this in MapKit (we have been doing this for 4 years, maybe there is a better way)
I would be so thankful for any help.
Best,
Michael
Recently I have updated my mobile version to iOS 18, since the day maps are not working in Apple Car Play since the update. The car display shows the message directions are not available in your location. Before the update it was working perfectly fine.
Topic:
App & System Services
SubTopic:
Maps & Location
I've started getting reports of this today and I am able to replicate it on my end but looking to see if anyone else can verify or if it's possibly regional to me (Canada).
In Apple Maps (iOS or macOS), if you search a latitude and longitude -- for example: "49.110,-112.110" and search, it centers on the location as it always has and shows the "Directions" button. When you tap the directions button, I get "A route can't be shown because of a problem connecting to the server.".
Alternatively, if you pass the coordinate in via Apple Maps URL (https://maps.apple.com/?daddr=49.110,-112.110) it will route but the route is no longer to those specific coordinates, Apple Maps alters them to some nearest known entity (in this case, the RM of Warner County). If you compare the suggested route end destination with the search results for specifically entering the coordinates, you will see they are different locations and mapping routes are not actually taking you to the coordinates anymore.
In the last photo attached, the arrow points to where "49.110,-112.110" is actually located which tapping the "Directions" button cannot figure out a route because of a server issue. If you pass it in via URL, it changes the destination coordinates and begins a route quite a ways away from the intended coordinate.
The problem started happening either this morning or last night.
Can anyone else confirm this happens to them?
Thanks,
Mike
I have a MKMapView with a MKScaleView.
If I visualise a generic map I have the scale in km.
When I change the MKMapRect using visibleMapRect, the scale doesn't change.
If I use setVisibleMapRect(_ mapRect: MKMapRect, animated animate: Bool), the scale change but not to the correct one. For example, it shows a scale saying one inch corresponds to 250 m while it is 150 m.
The same issue of I use MKCoordinateRegion.
Instead, if I zoom in or zoom out pinching on the map, the scale updates correctly.
Am I doing something wrong? How can I fix this?
Sample code:
import UIKit
import MapKit
let CORNER_RADIUS: CGFloat = 8.0
let METERS_PER_MILE: Double = 1609.344
class PIAnnotation: NSObject, MKAnnotation {
var coordinate: CLLocationCoordinate2D
private(set) var title: String?
private(set) var subtitle: String?
init(location: CLLocationCoordinate2D,
title: String? = nil, subtitle: String? = nil) {
coordinate = location
self.title = title
self.subtitle = subtitle
}
}
class PISimpleMapView: MKMapView {
private let HALF_MAP_SIDE_MULTIPLIER: Double = 1.4
private let pinIdentifier = "pinIdentifier"
private var scaleView: MKScaleView?
typealias PinAnnotationView = MKMarkerAnnotationView // MKPinAnnotationView
required init?(coder: NSCoder) {
super.init(coder: coder)
inizialize()
}
override init(frame: CGRect) {
super.init(frame: frame)
inizialize()
}
func inizialize() {
layer.cornerRadius = CORNER_RADIUS
register(PinAnnotationView.self,
forAnnotationViewWithReuseIdentifier: pinIdentifier)
addScale()
}
private func addScale() {
let scale = MKScaleView(mapView: self)
scale.translatesAutoresizingMaskIntoConstraints = false
scale.scaleVisibility = .visible // always visible
addSubview(scale)
let guide = safeAreaLayoutGuide
NSLayoutConstraint.activate([
scale.leftAnchor.constraint(equalTo: guide.leftAnchor, constant: 16.0),
scale.rightAnchor.constraint(equalTo: guide.centerXAnchor),
scale.topAnchor.constraint(equalTo: guide.topAnchor),
scale.heightAnchor.constraint(equalToConstant: 20.0)
])
scaleView?.removeFromSuperview()
scaleView = scale
}
func displayPinOnMap(location: CLLocation) {
let annotation = PIAnnotation(location: location.coordinate,
title: "Sample", subtitle: nil)
addAnnotation(annotation)
// Position the map so that all overlays and annotations are visible on screen.
visibleMapRect = visibleArea(from: annotation)
// setVisibleMapRect(visibleArea(from: annotation), animated: true)
// region = MKCoordinateRegion(visibleArea(from: annotation))
}
private func visibleArea(from annotation: PIAnnotation) -> MKMapRect {
let annotationPoint = MKMapPoint(annotation.coordinate)
return MKMapRect(x: annotationPoint.x - HALF_MAP_SIDE_MULTIPLIER * METERS_PER_MILE,
y: annotationPoint.y - HALF_MAP_SIDE_MULTIPLIER * METERS_PER_MILE,
width: HALF_MAP_SIDE_MULTIPLIER * 2.0 * METERS_PER_MILE,
height: HALF_MAP_SIDE_MULTIPLIER * 2.0 * METERS_PER_MILE)
}
}
It’s taking longer to get direction after you put the addres.
Topic:
App & System Services
SubTopic:
Maps & Location
On iOS 16 and below, the Apple logo is not displayed (Leagal labe is displayed).
On iOS 17, both logo and legal are displayed.
I have not specified layoutMergin for MKMapView.
Map View attribute inspector has specified standard settings
Why is only Apple Logo is not displayed ?
Thank you
CarPlay doesn’t work after updating to the iOS 18 and it worked perfectly fine before the update this need to be fixed I’ve tried everything
I am trying to retrieve the ellipsoidal altitude from a CLLocation but it seems like an invalid value is always returned, no matter the vertical accuracy (which according to the documentation should just be > 0) I first encountered this problem while developing a tool to retrieve workouts from healthkit, but i tried this code in a playground and i still get zero.
import CoreLocation
var location = CLLocation(coordinate: CLLocationCoordinate2D(latitude: 46.071067, longitude: 13.234579), altitude: 113, horizontalAccuracy: CLLocationAccuracy(floatLiteral: 1.0), verticalAccuracy: CLLocationAccuracy(floatLiteral: 1.0), timestamp: Date())
print(location.ellipsoidalAltitude)
Am I doing something wrong or is this a bug?
When I call requestWhenInUseAuthorization in state kCLAuthorizationStatusNotDetermined on iOS 18 Beta 4 in the simulator, all my apps just terminate without any error message in the Xcode console (black screen with an activity indicator for a second or two and then it goes back to the springboard). I do have the NSLocationWhenInUseUsageDescription set in my Info.plist file.
When running the exact same apps in Xcode 16.0 beta 4 (16A5211f) but with a iOS 17 simulator attached, it is working as expected by showing the location authorization dialog.
Is this a known issue or am I missing something?
I'm trying to create a UIImage from a MKLookAroundScene, after the user has moved the scene, by looking (and moving) around. Is this possible?
When I use MKLookAroundSnapshotter with the modified scene, I always get an image of the original (starting) scene.
STEPS TO REPRODUCE
Create a scene using MKLookAroundSceneRequest with coordinates.
Use LookAroundPreview with a binding to MKLookAroundScene to get changes to the scene (based on looking around).
User begins LookAround, moving the scene location and view.
User ends LookAround
The preview displays the updated scene properly.
The scene's cameraFrameOverride values reflect the pitch, roll, yaw, and location changes.
Pass the updated scene to MKLookAroundSnapshotter to get an image.
Display the Image.
The Image is the original scene (not what is displayed in the preview).
I am trying to use MapKit JS in Tauri and Flutter desktop apps but I can‘t because if I want the key not to expire I have to whitelist a domain but my apps don't run on the web and therefore don't have a valid domain.
I might be being really ******, but I'm struggling to find a way to update the map kit token when it expires. We have a display that shows a map for a long time and for some reason the map stops loading and I think it's cause the token expires however I can't work out away to tell it to load a new token.
I have a CarPlay navigation app and I would like to allow the user to speak an address and have our app search at that location.
In the Waze app, it provides a button to tap, then it brings up a CPVoiceControlTemplate and you can give it directions or a location and it will then show you search results including the text you spoke as the title. I assume that app would have the same limitations as I do, so I am wondering how another app might do this?
It was suggested that I use an App Intent with suggested phrases and then a Shortcut could perform the action. Is there documentation on this somewhere or am I going in the wrong direction here?
Obviously Waze is doing what I am wanting so there must be a way. Can anyone point me in the right direction?
I am looking into a piece of old code where the mentioned method is called.
+ (bool)isLocationServicesEnabled {
return [CLLocationManager locationServicesEnabled];
}
I'm getting the classic "This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first."
I have 2 questions:
What is that error about, really? The locationServicesEnabled() has nothing to do with authorisation, it's just about the "location services" settings global on-off switch? (the authorisation check is .authorizationStatus)
I don't understand why that call is such a big issue? It's just a setting? Why would that be so costly?
Thankful for pointers! Have a good one
We met a question recently in our project, we try to achieve the SSID,so we need to do the following two things :
request location permission
add the capability of "Access Wi-Fi information"
then the app always shows the location access indicator.
, In the app privacy report , we see the app always request the location.
But when I try to remove "Access Wi-Fi information" the capability , the scenario disappear.
Any ideas can explain this ? How can I remove the location access indicator with out remove the "Access Wi-Fi information" . I indeed need this.
Thanks in advance.
Is it possible to fetch the user's latitude and longitude after the app has been manually terminated? If so, could you please provide a solution?