Skip to content

Commit 8bf217b

Browse files
authored
Use navigation location provider (#178)
* Prepare `5.0.0-pre3` release * Use highest available location provider on iOS for navigation on * Add missing configuration for iOS sample app * Prepare 5.0.0-pre10 release * Add activity type to apple location manager * Don't pause apple location updates
1 parent bb9e17a commit 8bf217b

6 files changed

Lines changed: 26 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ MapLibre welcomes participation and contributions from everyone.
55

66
## Unreleased
77

8+
### v5.0.0-pre10 - Aug 22, 2025
9+
10+
- Use highest location provider on iOS [#178](https://github.com/maplibre/maplibre-navigation-android/pull/178)
811
- Improve AppleLocationEngine time-out behavior [#176](https://github.com/maplibre/maplibre-navigation-android/pull/176)
912

1013
### v5.0.0-pre9 - Jul 11, 2025

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ This library is available on Maven Central. To use it, add the following to your
4646
Step 2. Add the dependency
4747
```groovy
4848
// Core KMP library (without UI)
49-
implementation 'org.maplibre.navigation:navigation-core:5.0.0-pre4'
49+
implementation 'org.maplibre.navigation:navigation-core:5.0.0-pre10'
5050
5151
// UI library (Android only)
52-
implementation 'org.maplibre.navigation:navigation-ui-android:5.0.0-pre4'
52+
implementation 'org.maplibre.navigation:navigation-ui-android:5.0.0-pre10'
5353
```
5454

5555

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.0.0-pre9
1+
5.0.0-pre10

maplibre-navigation-core/src/iosMain/kotlin/org/maplibre/navigation/core/location/engine/AppleLocationEngine.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ import kotlinx.coroutines.withContext
1212
import kotlinx.coroutines.withTimeoutOrNull
1313
import org.maplibre.navigation.core.location.Location
1414
import org.maplibre.navigation.core.location.toLocation
15+
import platform.CoreLocation.CLActivityType
16+
import platform.CoreLocation.CLActivityTypeAutomotiveNavigation
1517
import platform.CoreLocation.CLLocationManager
1618
import platform.CoreLocation.CLLocationManagerDelegateProtocol
19+
import platform.CoreLocation.kCLLocationAccuracyBest
20+
import platform.CoreLocation.kCLLocationAccuracyBestForNavigation
1721
import platform.Foundation.NSError
1822
import platform.darwin.NSObject
1923
import kotlin.coroutines.resume
@@ -51,6 +55,9 @@ open class AppleLocationEngine(private val getLocationTimeout: Duration, private
5155
* The underlying CLLocationManager instance used to fetch location updates.
5256
*/
5357
private val locationManager = CLLocationManager().also { locationManager ->
58+
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
59+
locationManager.activityType = CLActivityTypeAutomotiveNavigation
60+
locationManager.pausesLocationUpdatesAutomatically = false
5461
locationManager.allowsBackgroundLocationUpdates = enableBackgroundLocationUpdates
5562
locationManager.delegate = locationDelegate
5663
}
@@ -89,8 +96,11 @@ open class AppleLocationEngine(private val getLocationTimeout: Duration, private
8996
* @return The current [Location] or null if unavailable or the timeout is exceeded.
9097
*/
9198
private suspend fun getLocation(timeout: Duration): Location? = withContext(Dispatchers.Main) {
92-
val locationManager = CLLocationManager().also {
93-
it.allowsBackgroundLocationUpdates = enableBackgroundLocationUpdates
99+
val locationManager = CLLocationManager().also { locationManager ->
100+
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
101+
locationManager.activityType = CLActivityTypeAutomotiveNavigation
102+
locationManager.pausesLocationUpdatesAutomatically = false
103+
locationManager.allowsBackgroundLocationUpdates = enableBackgroundLocationUpdates
94104
}
95105

96106
withTimeoutOrNull(timeout) {

sample/ios/ML Nav - iOS Sample App.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@
223223
DEVELOPMENT_TEAM = "";
224224
GENERATE_INFOPLIST_FILE = YES;
225225
INFOPLIST_FILE = "ML Nav - iOS Sample App/Info.plist";
226-
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Location is used to showing your position on current navigation route";
226+
INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "Using location for navigation";
227+
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Using location for navigation";
227228
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
228229
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
229230
INFOPLIST_KEY_UIMainStoryboardFile = Main;
@@ -255,7 +256,8 @@
255256
DEVELOPMENT_TEAM = "";
256257
GENERATE_INFOPLIST_FILE = YES;
257258
INFOPLIST_FILE = "ML Nav - iOS Sample App/Info.plist";
258-
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Location is used to showing your position on current navigation route";
259+
INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "Using location for navigation";
260+
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Using location for navigation";
259261
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
260262
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
261263
INFOPLIST_KEY_UIMainStoryboardFile = Main;

sample/ios/ML Nav - iOS Sample App/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@
2121
</array>
2222
</dict>
2323
</dict>
24+
<key>UIBackgroundModes</key>
25+
<array>
26+
<string>location</string>
27+
</array>
2428
</dict>
2529
</plist>

0 commit comments

Comments
 (0)