navigation_with_mapbox 0.0.1
navigation_with_mapbox: ^0.0.1 copied to clipboard
Add Turn By Turn Navigation to Your Flutter Application Using MapBox.
navigation_with_mapbox #
Add Turn By Turn Navigation to Your Flutter Application Using MapBox.
Android Configuration #
- Mapbox APIs and vector tiles require a Mapbox account and API access token. Add your token in strings.xml file of your android apps res/values/ path. The string key should be "mapbox_access_token". You can obtain an access token from the Mapbox account page.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="mapbox_access_token" translatable="false">ADD_MAPBOX_ACCESS_TOKEN_HERE</string>
</resources>
- Add the following permissions to the app level Android Manifest
<manifest>
...
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
...
</manifest>
- Add the MapBox Downloads token with the
downloads:read
scope to your gradle.properties file in Android folder to enable downloading the MapBox binaries from the repository. To secure this token from getting checked into source control, you can add it to the gradle.properties of your GRADLE_HOME which is usually at $USER_HOME/.gradle for Mac. This token can be retrieved from your MapBox Dashboard. You can review the Token Guide to learn more about download tokens
MAPBOX_DOWNLOADS_TOKEN=sk.XXXXXXXXXXXXXXX
After adding the above, your gradle.properties file may look something like this:
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
MAPBOX_DOWNLOADS_TOKEN=sk.XXXXXXXXXXXXXXX
Usage #
Declare an instance
() async {
await _navigationWithMapboxPlugin.startNavigation(
origin: WayPoint(latitude: 4.809432, longitude: -75.700660),
destination:
WayPoint(latitude: 4.759335, longitude: -75.923914),
setDestinationWithTap: false,
simulateRoute: false,
msg: '¡Enjoy!', // optional
profile: '', // optional, default: driving, others: walking, cycling
style: '', // optional, default: streets, others: dark, light, traffic_day, traffic_night, satellite, satellite_streets, outdoors
voiceUnits: '', // optional, default: metric
language: '', // optional, default: en
alternativeRoute: true // optional, default: false
);
}