Skip to content

navigation sdk integration (android + ios) #773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fd553a5
navigation sdk integration (android only)
OlegKrymskyi Nov 17, 2024
e37d50c
change log update
OlegKrymskyi Nov 17, 2024
39d51d3
clean up example
OlegKrymskyi Nov 17, 2024
a6fcedd
fix camera animation duration
OlegKrymskyi Nov 17, 2024
e298bba
add missed await
OlegKrymskyi Nov 17, 2024
caf5285
ios
OlegKrymskyi Dec 30, 2024
bb42b9d
rework navigation
OlegKrymskyi Dec 30, 2024
e6e5583
navigation add listener
OlegKrymskyi Dec 30, 2024
5398d4f
podspec with navigation
OlegKrymskyi Jan 3, 2025
90a4545
fix pods
OlegKrymskyi Jan 4, 2025
fad16f9
pod spec
OlegKrymskyi Jan 8, 2025
7a8699e
checkout navigation sdk to the classes
OlegKrymskyi Jan 9, 2025
3f78b6f
Merge branch 'feature/ios' of https://github.com/OlegKrymskyi/mapbox-…
OlegKrymskyi Jan 9, 2025
63de19b
fixed pod file
OlegKrymskyi Jan 26, 2025
5b01464
fixed compile error, except one
OlegKrymskyi Jan 26, 2025
db92462
delete link
OlegKrymskyi Jan 26, 2025
b9cc1d1
flt mapping
OlegKrymskyi Feb 1, 2025
b71e1ac
static navigation provider
OlegKrymskyi Feb 7, 2025
0f62d9b
right way to do this
OlegKrymskyi Feb 8, 2025
4d5e59b
one more step ahead
OlegKrymskyi Feb 8, 2025
c9b9d02
more progress
OlegKrymskyi Feb 8, 2025
743b08f
try to use navigation view
OlegKrymskyi Feb 9, 2025
7924b80
it works
OlegKrymskyi Feb 9, 2025
a442b0b
events generation
OlegKrymskyi Feb 9, 2025
336e72c
fix pod spec
OlegKrymskyi Feb 9, 2025
99e5c3e
rollback access token
OlegKrymskyi Feb 9, 2025
024d3c8
Merge pull request #1 from OlegKrymskyi/feature/ios-2
OlegKrymskyi Feb 9, 2025
57aad5b
android latest location
OlegKrymskyi Feb 12, 2025
a22320b
ndk27 support
OlegKrymskyi Feb 28, 2025
b0d323a
fix
OlegKrymskyi Mar 3, 2025
48f84c1
navigation route
OlegKrymskyi Mar 3, 2025
fc85def
route options
OlegKrymskyi Mar 4, 2025
550dfb8
route options ios
OlegKrymskyi Mar 4, 2025
d1a0a54
fix example
OlegKrymskyi Mar 4, 2025
bbc1898
fix ios build
OlegKrymskyi Mar 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,7 @@ app.*.symbols
!/dev/ci/**/Gemfile.lock
!**/Podfile.lock
!**/example/pubspec.lock
android/gradlew
android/gradle/wrapper/gradle-wrapper.jar
example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
example/ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
> [!IMPORTANT]
> Configuring Mapbox's secret token is no longer required when installing our SDKs.

### 2.4.1
* Integrates Navigation SDK with the Mapbox View.

### 2.4.0

* Update Maps SDK to 11.8.0
Expand Down
39 changes: 34 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
}
}

Expand All @@ -78,8 +78,37 @@ if (file("$rootDir/gradle/ktlint.gradle").exists() && file("$rootDir/gradle/lint
}

dependencies {
implementation "com.mapbox.maps:android:11.8.0"

implementation "androidx.annotation:annotation:1.5.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
implementation "com.google.android.gms:play-services-location:21.0.1"

implementation "com.mapbox.common:common-ndk27:24.8.0"
implementation "com.mapbox.maps:android-core-ndk27:11.8.0"
implementation "com.mapbox.maps:android-ndk27:11.8.0"
implementation ("com.mapbox.navigationcore:navigation:3.5.0") {
exclude group: "com.mapbox.common", module: "common"
exclude group: "com.mapbox.maps", module: "android"
exclude group: "com.mapbox.maps", module: "base"
exclude group: "com.mapbox.maps", module: "android-core"
}
implementation ("com.mapbox.navigationcore:ui-components:3.5.0") {
exclude group: "com.mapbox.common", module: "common"
exclude group: "com.mapbox.maps", module: "android"
exclude group: "com.mapbox.maps", module: "base"
exclude group: "com.mapbox.maps", module: "android-core"
}

configurations.all {
resolutionStrategy {
force "com.mapbox.maps:android-ndk27:11.8.0"
force "com.mapbox.maps:base-ndk27:11.8.0"
force "com.mapbox.common:common-ndk27:24.8.0"
force "com.mapbox.maps:android-core-ndk27:11.8.0"
force "com.mapbox.plugin:maps-locationcomponent-ndk27:11.8.0"
force "com.mapbox.plugin:maps-lifecycle-ndk27:11.8.0"
force "com.mapbox.plugin:maps-gestures-ndk27:11.8.0"
force "com.mapbox.plugin:maps-viewport-ndk27:11.8.0"
force "com.mapbox.module:maps-telemetry-ndk27:11.8.0"
}
}
}
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx4096M
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
4 changes: 3 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
5 changes: 3 additions & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapbox.maps.mapbox_maps">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import com.mapbox.maps.mapbox_maps.pigeons._AnimationManager
import com.mapbox.maps.mapbox_maps.pigeons._CameraManager
import com.mapbox.maps.mapbox_maps.pigeons._LocationComponentSettingsInterface
import com.mapbox.maps.mapbox_maps.pigeons._MapInterface
import com.mapbox.maps.mapbox_maps.pigeons.NavigationInterface
import com.mapbox.maps.plugin.locationcomponent.location
import com.mapbox.navigation.ui.maps.location.NavigationLocationProvider
import io.flutter.embedding.android.FlutterActivity
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.MethodCall
Expand Down Expand Up @@ -64,9 +67,16 @@ class MapboxMapController(
private val attributionController: AttributionController
private val scaleBarController: ScaleBarController
private val compassController: CompassController
private var navigationController: NavigationController? = null

private val eventHandler: MapboxEventHandler

/**
* [NavigationLocationProvider] is a utility class that helps to provide location updates generated by the Navigation SDK
* to the Maps SDK in order to update the user location indicator on the map.
*/
private val navigationLocationProvider = NavigationLocationProvider()

/*
Mirrors lifecycle of the parent, with one addition - switches to DESTROYED state
when `dispose` is called.
Expand Down Expand Up @@ -177,21 +187,29 @@ class MapboxMapController(
false -> true
}
lifecycleHelper = LifecycleHelper(lifecycleProvider.getLifecycle()!!, shouldDestroyOnDestroy)

mapView?.location?.setLocationProvider(navigationLocationProvider)
mapView?.setViewTreeLifecycleOwner(lifecycleHelper)

navigationController = NavigationController(context, mapView!!, lifecycleProvider.getLifecycle()!!)

NavigationInterface.setUp(messenger, navigationController, channelSuffix)
}

override fun onFlutterViewDetached() {
super.onFlutterViewDetached()
lifecycleHelper?.dispose()
lifecycleHelper = null
navigationController?.dispose()
navigationController = null
mapView!!.setViewTreeLifecycleOwner(null)
}

override fun dispose() {
if (mapView == null) {
return
}
navigationController?.dispose()
navigationController = null
lifecycleHelper?.dispose()
lifecycleHelper = null
mapView = null
Expand All @@ -209,6 +227,7 @@ class MapboxMapController(
CompassSettingsInterface.setUp(messenger, null, channelSuffix)
ScaleBarSettingsInterface.setUp(messenger, null, channelSuffix)
AttributionSettingsInterface.setUp(messenger, null, channelSuffix)
NavigationInterface.setUp(messenger, null, channelSuffix)
}

override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
Expand All @@ -227,6 +246,14 @@ class MapboxMapController(
gestureController.removeListeners()
result.success(null)
}
"navigation#add_listeners" -> {
navigationController?.addListeners(messenger, channelSuffix)
result.success(null)
}
"navigation#remove_listeners" -> {
navigationController?.removeListeners()
result.success(null)
}
"platform#releaseMethodChannels" -> {
dispose()
result.success(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import android.content.Context
import androidx.lifecycle.Lifecycle
import com.mapbox.maps.mapbox_maps.offline.OfflineMapInstanceManager
import com.mapbox.maps.mapbox_maps.offline.OfflineSwitch
import com.mapbox.maps.mapbox_maps.pigeons.NavigationInterface
import com.mapbox.maps.mapbox_maps.pigeons._MapboxMapsOptions
import com.mapbox.maps.mapbox_maps.pigeons._MapboxOptions
import com.mapbox.maps.mapbox_maps.pigeons._OfflineMapInstanceManager
import com.mapbox.maps.mapbox_maps.pigeons._OfflineSwitch
import com.mapbox.maps.mapbox_maps.pigeons._SnapshotterInstanceManager
import com.mapbox.maps.mapbox_maps.pigeons._TileStoreInstanceManager
import com.mapbox.maps.mapbox_maps.snapshot.SnapshotterInstanceManager
import com.mapbox.navigation.base.options.NavigationOptions
import com.mapbox.navigation.core.lifecycle.MapboxNavigationApp
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterAssets
import io.flutter.embedding.engine.plugins.activity.ActivityAware
Expand Down Expand Up @@ -38,6 +41,11 @@ class MapboxMapsPlugin : FlutterPlugin, ActivityAware {
)
)
setupStaticChannels(flutterPluginBinding.applicationContext, flutterPluginBinding.binaryMessenger, flutterPluginBinding.flutterAssets)

MapboxNavigationApp.setup(
NavigationOptions.Builder(flutterPluginBinding.applicationContext)
.build()
)
}

private fun setupStaticChannels(context: Context, binaryMessenger: BinaryMessenger, flutterAssets: FlutterAssets) {
Expand Down
Loading