├── ios ├── Assets │ └── .gitkeep ├── Classes │ ├── models │ │ ├── RouteEvent.swift │ │ ├── Feedback.swift │ │ ├── RouteStep.swift │ │ ├── Location.swift │ │ ├── EventType.swift │ │ ├── RouteLeg.swift │ │ └── RouteProgressEvent.swift │ ├── NavigationViewFactory.swift │ ├── styles │ │ ├── Day.swift │ │ └── Night.swift │ ├── FreeDriveViewController.swift │ └── FlutterMapboxNavigationPlugin.swift ├── .gitignore └── flutter_mapbox_navigation.podspec ├── example ├── linux │ ├── .gitignore │ ├── main.cc │ ├── flutter │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ ├── my_application.h │ └── my_application.cc ├── ios │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── .gitignore │ ├── Podfile │ └── Podfile.lock ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── manifest.json │ └── index.html ├── macos │ ├── Runner │ │ ├── Configs │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ ├── Warnings.xcconfig │ │ │ └── AppInfo.xcconfig │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ ├── app_icon_64.png │ │ │ │ ├── app_icon_1024.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Release.entitlements │ │ ├── DebugProfile.entitlements │ │ ├── MainFlutterWindow.swift │ │ └── Info.plist │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ └── Podfile ├── lib │ └── main.dart ├── windows │ ├── runner │ │ ├── resources │ │ │ └── app_icon.ico │ │ ├── resource.h │ │ ├── utils.h │ │ ├── runner.exe.manifest │ │ ├── flutter_window.h │ │ ├── main.cpp │ │ ├── CMakeLists.txt │ │ ├── utils.cpp │ │ ├── flutter_window.cpp │ │ ├── Runner.rc │ │ └── win32_window.h │ ├── flutter │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ ├── .gitignore │ └── CMakeLists.txt ├── android │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── values-night │ │ │ │ │ │ └── styles.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── eopeter │ │ │ │ │ │ └── fluttermapboxnavigationexample │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── settings.gradle │ └── build.gradle ├── README.md ├── .gitignore ├── test │ └── widget_test.dart ├── analysis_options.yaml └── pubspec.yaml ├── android ├── settings.gradle ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ └── layout │ │ │ ├── navigation_activity.xml │ │ │ └── components_navigation_activity.xml │ │ ├── kotlin │ │ └── com │ │ │ └── eopeter │ │ │ └── fluttermapboxnavigation │ │ │ ├── models │ │ │ ├── MapBoxLocation.kt │ │ │ ├── MapBoxMileStone.kt │ │ │ ├── MapBoxRouteStep.kt │ │ │ ├── MapBoxEvents.kt │ │ │ ├── Waypoint.kt │ │ │ ├── MapBoxRouteLeg.kt │ │ │ ├── WaypointSet.kt │ │ │ ├── MapBoxRouteProgressEvent.kt │ │ │ └── views │ │ │ │ └── EmbeddedNavigationMapView.kt │ │ │ ├── activity │ │ │ └── NavigationLauncher.java │ │ │ ├── factory │ │ │ └── EmbeddedNavigationViewFactory.kt │ │ │ └── utilities │ │ │ └── CustomInfoPanelEndNavButtonBinder.kt │ │ └── AndroidManifest.xml └── build.gradle ├── .pubignore ├── screenshots ├── screenshot1.png ├── screenshot2.png ├── screenshot3.png └── screenshot4.png ├── lib ├── src │ ├── helpers.dart │ ├── models │ │ ├── voice_units.dart │ │ ├── models.dart │ │ ├── navmode.dart │ │ ├── event_data.dart │ │ ├── feedback.dart │ │ ├── events.dart │ │ ├── route_step.dart │ │ ├── route_event.dart │ │ ├── way_point.dart │ │ ├── route_leg.dart │ │ └── route_progress_event.dart │ ├── flutter_mapbox_navigation_web.dart │ ├── embedded │ │ └── view.dart │ ├── flutter_mapbox_navigation_platform_interface.dart │ └── flutter_mapbox_navigation.dart └── flutter_mapbox_navigation.dart ├── analysis_options.yaml ├── windows ├── .gitignore ├── flutter_mapbox_navigation_plugin_c_api.cpp ├── include │ └── flutter_mapbox_navigation │ │ └── flutter_mapbox_navigation_plugin_c_api.h ├── flutter_mapbox_navigation_plugin.h ├── flutter_mapbox_navigation_plugin.cpp └── CMakeLists.txt ├── .github └── workflows │ ├── stale.yml │ └── linter.yml ├── test ├── flutter_mapbox_navigation_method_channel_test.dart └── flutter_mapbox_navigation_test.dart ├── macos ├── Classes │ └── FlutterMapboxNavigationPlugin.swift └── flutter_mapbox_navigation.podspec ├── .gitignore ├── flutter_mapbox_navigation.iml ├── linux ├── include │ └── flutter_mapbox_navigation │ │ └── flutter_mapbox_navigation_plugin.h ├── CMakeLists.txt └── flutter_mapbox_navigation_plugin.cc ├── pubspec.yaml ├── .metadata └── CHANGELOG.md /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_mapbox_navigation' 2 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /.pubignore: -------------------------------------------------------------------------------- 1 | .idea/.gitignore 2 | .idea/misc.xml 3 | .idea/modules.xml 4 | flutter_mapbox_navigation.iml 5 | pubspec.lock -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/web/favicon.png -------------------------------------------------------------------------------- /screenshots/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/screenshots/screenshot1.png -------------------------------------------------------------------------------- /screenshots/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/screenshots/screenshot2.png -------------------------------------------------------------------------------- /screenshots/screenshot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/screenshots/screenshot3.png -------------------------------------------------------------------------------- /screenshots/screenshot4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/screenshots/screenshot4.png -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /lib/src/helpers.dart: -------------------------------------------------------------------------------- 1 | /// Checks if a num is 0 or null 2 | bool isNullOrZero(num? val) { 3 | return val == 0.0 || val == null; 4 | } 5 | -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'app.dart'; 4 | 5 | void main() => runApp(const SampleNavigationApp()); -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .cxx 10 | 11 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:very_good_analysis/analysis_options.yaml 2 | # Additional information about this file can be found at 3 | # https://dart.dev/guides/language/analysis-options 4 | -------------------------------------------------------------------------------- /lib/flutter_mapbox_navigation.dart: -------------------------------------------------------------------------------- 1 | export 'src/embedded/controller.dart'; 2 | export 'src/embedded/view.dart'; 3 | export 'src/flutter_mapbox_navigation.dart'; 4 | export 'src/models/models.dart'; 5 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eopeter/flutter_mapbox_navigation/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | 9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 10 | } 11 | -------------------------------------------------------------------------------- /lib/src/models/voice_units.dart: -------------------------------------------------------------------------------- 1 | ///Whether or not the units used inside the voice instruction's string are 2 | ///in imperial or metric. 3 | enum VoiceUnits { 4 | /// miles 5 | imperial, 6 | 7 | /// kilometers, gram, etc 8 | metric, 9 | } 10 | -------------------------------------------------------------------------------- /android/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2048m 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | kotlin.code.style=official 5 | MAPBOX_DOWNLOADS_TOKEN=sk.eyJ1IjoiZW9wZXRlciIsImEiOiJjbDZjNTY3NzAwYXVvM2txZnhic3l2MHI1In0.7IcU5AMyCMGoQ_J4-_ah8g -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/eopeter/fluttermapboxnavigationexample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigationexample 2 | 3 | import io.flutter.embedding.android.FlutterFragmentActivity 4 | 5 | class MainActivity: FlutterFragmentActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Error: no mapbox access token 3 | Please put your mapbox access token in res/values/mapbox_access_token.xml 4 | false 5 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Classes/models/RouteEvent.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class MapBoxRouteEvent : Codable 4 | { 5 | let eventType: MapBoxEventType 6 | let data: String 7 | 8 | init(eventType: MapBoxEventType, data: String) { 9 | self.eventType = eventType 10 | self.data = data 11 | } 12 | } -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/models/models.dart: -------------------------------------------------------------------------------- 1 | export 'event_data.dart'; 2 | export 'events.dart'; 3 | export 'feedback.dart'; 4 | export 'navmode.dart'; 5 | export 'options.dart'; 6 | export 'route_event.dart'; 7 | export 'route_leg.dart'; 8 | export 'route_progress_event.dart'; 9 | export 'route_step.dart'; 10 | export 'voice_units.dart'; 11 | export 'way_point.dart'; 12 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /lib/src/models/navmode.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: public_member_api_docs 2 | 3 | ///Option to specify the mode of transportation. 4 | @Deprecated('Use MapBoxNavigationMode instead') 5 | enum NavigationMode { walking, cycling, driving, drivingWithTraffic } 6 | 7 | ///Option to specify the mode of transportation. 8 | enum MapBoxNavigationMode { walking, cycling, driving, drivingWithTraffic } 9 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #2D4E73 4 | #2D4E73 5 | #2D4E73 6 | #2D4E73 7 | #FF0000 8 | #FFFFFF 9 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /ios/Classes/models/Feedback.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Feedback.swift 3 | // flutter_mapbox_navigation 4 | // 5 | // Created by Marco Galetta on 20/05/23. 6 | // 7 | 8 | import Foundation 9 | 10 | public class Feedback : Codable 11 | { 12 | let rating: Int? 13 | let comment: String? 14 | 15 | init(rating: Int?,comment: String?) { 16 | self.rating = rating 17 | self.comment = comment 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/models/MapBoxLocation.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.models 2 | 3 | class MapBoxLocation(val name: String = "", private val latitude: Double?, private val longitude: Double?) { 4 | override fun toString(): String { 5 | return "{" + 6 | " \"latitude\": $latitude," + 7 | " \"longitude\": $longitude" + 8 | "}" 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ios/Classes/models/RouteStep.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import MapboxDirections 3 | 4 | public class MapBoxRouteStep : Codable 5 | { 6 | let name: String? 7 | let instructions: String 8 | let distance: Double 9 | let expectedTravelTime: Double 10 | 11 | init(step: RouteStep){ 12 | name = step.names?.first 13 | instructions = step.instructions 14 | distance = step.distance 15 | expectedTravelTime = step.expectedTravelTime 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /ios/Classes/models/Location.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class Location : Codable 4 | { 5 | let name: String 6 | let latitude: Double? 7 | let longitude: Double? 8 | let order: Int? 9 | let isSilent: Bool 10 | 11 | init(name: String, latitude: Double?, longitude: Double?, order: Int? = nil, isSilent: Bool = false) { 12 | self.name = name 13 | self.latitude = latitude 14 | self.longitude = longitude 15 | self.order = order 16 | self.isSilent = isSilent 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | 3 | on: 4 | schedule: 5 | - cron: "30 1 * * *" 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | environment: dev 13 | steps: 14 | - uses: actions/stale@v1 15 | with: 16 | repo-token: ${{ secrets.MAPBOX_NAVIGATION_GITHUB_TOKEN }} 17 | stale-issue-message: 'Stale issue message' 18 | stale-pr-message: 'Stale pull request message' 19 | stale-issue-label: 'no-issue-activity' 20 | stale-pr-label: 'no-pr-activity' 21 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /windows/flutter_mapbox_navigation_plugin_c_api.cpp: -------------------------------------------------------------------------------- 1 | #include "include/flutter_mapbox_navigation/flutter_mapbox_navigation_plugin_c_api.h" 2 | 3 | #include 4 | 5 | #include "flutter_mapbox_navigation_plugin.h" 6 | 7 | void FlutterMapboxNavigationPluginCApiRegisterWithRegistrar( 8 | FlutterDesktopPluginRegistrarRef registrar) { 9 | flutter_mapbox_navigation::FlutterMapboxNavigationPlugin::RegisterWithRegistrar( 10 | flutter::PluginRegistrarManager::GetInstance() 11 | ->GetRegistrar(registrar)); 12 | } 13 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/ephemeral/ 38 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /lib/src/models/event_data.dart: -------------------------------------------------------------------------------- 1 | ///Data associated with a Route Event 2 | class MapBoxEventData { 3 | /// Coonstructior 4 | MapBoxEventData({this.data}); 5 | 6 | /// Create [MapBoxEventData] object from a json 7 | MapBoxEventData.fromJson(Map json) { 8 | data = json['data'] as String; 9 | } 10 | 11 | /// Create json from [MapBoxEventData] 12 | Map toJson() { 13 | final data = {}; 14 | data['data'] = this.data; 15 | return data; 16 | } 17 | 18 | /// Field containing data about associated RouteEvent 19 | String? data; 20 | } 21 | -------------------------------------------------------------------------------- /ios/Classes/models/EventType.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | enum MapBoxEventType: String, Codable 4 | { 5 | case map_ready 6 | case route_building 7 | case route_built 8 | case route_build_failed 9 | case progress_change 10 | case user_off_route 11 | case milestone_event 12 | case navigation_running 13 | case navigation_cancelled 14 | case navigation_finished 15 | case faster_route_found 16 | case speech_announcement 17 | case banner_instruction 18 | case on_arrival 19 | case failed_to_reroute 20 | case reroute_along 21 | case on_map_tap 22 | } 23 | -------------------------------------------------------------------------------- /android/src/main/res/layout/navigation_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 12 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/models/MapBoxMileStone.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.models 2 | 3 | data class MapBoxMileStone( 4 | var identifier: Int?, 5 | val distanceTraveled: Double?, 6 | var legIndex: Int?, 7 | var stepIndex: Int? 8 | ) { 9 | override fun toString(): String { 10 | return "{" + 11 | " \"identifier\": \"$identifier\"," + 12 | " \"distanceTraveled\": $distanceTraveled," + 13 | " \"legIndex\": \"$legIndex\"," + 14 | " \"stepIndex\": \"$stepIndex\"" + 15 | "}" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/src/models/feedback.dart: -------------------------------------------------------------------------------- 1 | /// This class contains rating and comment from the user when 2 | /// navigation ends on iOS 3 | class MapBoxFeedback { 4 | /// Constructor 5 | MapBoxFeedback({this.rating, this.comment}); 6 | 7 | /// return [MapBoxFeedback] from a json 8 | MapBoxFeedback.fromJson(Map json) { 9 | rating = json['rating'] != null ? json['rating'] as int : null; 10 | comment = json['comment'] != null ? json['comment'] as String : null; 11 | } 12 | 13 | /// Rating 0-100 corresponding to the stars selection in iOS feedback 14 | int? rating; 15 | 16 | /// String comment 17 | String? comment; 18 | } 19 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /lib/src/models/events.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: constant_identifier_names, public_member_api_docs 2 | 3 | /// All possible events that could occur in the course of navigation 4 | enum MapBoxEvent { 5 | map_ready, 6 | route_building, 7 | route_built, 8 | route_build_failed, 9 | route_build_cancelled, 10 | route_build_no_routes_found, 11 | progress_change, 12 | user_off_route, 13 | milestone_event, 14 | navigation_running, 15 | navigation_cancelled, 16 | navigation_finished, 17 | faster_route_found, 18 | speech_announcement, 19 | banner_instruction, 20 | on_arrival, 21 | failed_to_reroute, 22 | reroute_along, 23 | on_map_tap 24 | } 25 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_mapbox_navigation_example 2 | 3 | Demonstrates how to use the flutter_mapbox_navigation plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = flutter_mapbox_navigation_example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.eopeter.flutterMapboxNavigationExample 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.eopeter. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/include/flutter_mapbox_navigation/flutter_mapbox_navigation_plugin_c_api.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_PLUGIN_FLUTTER_MAPBOX_NAVIGATION_PLUGIN_C_API_H_ 2 | #define FLUTTER_PLUGIN_FLUTTER_MAPBOX_NAVIGATION_PLUGIN_C_API_H_ 3 | 4 | #include 5 | 6 | #ifdef FLUTTER_PLUGIN_IMPL 7 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) 8 | #else 9 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) 10 | #endif 11 | 12 | #if defined(__cplusplus) 13 | extern "C" { 14 | #endif 15 | 16 | FLUTTER_PLUGIN_EXPORT void FlutterMapboxNavigationPluginCApiRegisterWithRegistrar( 17 | FlutterDesktopPluginRegistrarRef registrar); 18 | 19 | #if defined(__cplusplus) 20 | } // extern "C" 21 | #endif 22 | 23 | #endif // FLUTTER_PLUGIN_FLUTTER_MAPBOX_NAVIGATION_PLUGIN_C_API_H_ 24 | -------------------------------------------------------------------------------- /test/flutter_mapbox_navigation_method_channel_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_mapbox_navigation/src/flutter_mapbox_navigation_method_channel.dart'; 3 | import 'package:flutter_test/flutter_test.dart'; 4 | 5 | void main() { 6 | final platform = MethodChannelFlutterMapboxNavigation(); 7 | const channel = MethodChannel('flutter_mapbox_navigation'); 8 | 9 | TestWidgetsFlutterBinding.ensureInitialized(); 10 | 11 | setUp(() { 12 | TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger 13 | .setMockMethodCallHandler(channel, (MethodCall methodCall) async { 14 | return '42'; 15 | }); 16 | }); 17 | 18 | test('getPlatformVersion', () async { 19 | expect(await platform.getPlatformVersion(), '42'); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /macos/Classes/FlutterMapboxNavigationPlugin.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | public class FlutterMapboxNavigationPlugin: NSObject, FlutterPlugin { 5 | public static func register(with registrar: FlutterPluginRegistrar) { 6 | let channel = FlutterMethodChannel(name: "flutter_mapbox_navigation", binaryMessenger: registrar.messenger) 7 | let instance = FlutterMapboxNavigationPlugin() 8 | registrar.addMethodCallDelegate(instance, channel: channel) 9 | } 10 | 11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 12 | switch call.method { 13 | case "getPlatformVersion": 14 | result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString) 15 | default: 16 | result(FlutterMethodNotImplemented) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | pubspec.lock 27 | 28 | **/doc/api/ 29 | .dart_tool/ 30 | .packages 31 | build/ 32 | 33 | example/android/app/src/main/res/values/mapbox_access_token.xml 34 | example/android/app/src/main/res/values/strings.xml 35 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | ext.android_gradle_version = '7.4.2' 4 | repositories { 5 | google() 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | classpath "com.android.tools.build:gradle:$android_gradle_version" 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | rootProject.buildDir = '../build' 23 | subprojects { 24 | project.buildDir = "${rootProject.buildDir}/${project.name}" 25 | } 26 | subprojects { 27 | project.evaluationDependsOn(':app') 28 | } 29 | 30 | tasks.register("clean", Delete) { 31 | delete rootProject.buildDir 32 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/models/MapBoxRouteStep.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.models 2 | 3 | import com.google.gson.JsonObject 4 | import com.mapbox.api.directions.v5.models.LegStep 5 | 6 | class MapBoxRouteStep(private val step: LegStep) { 7 | 8 | private val instructions: String = "" //step.bannerInstructions()[0]?.primary().toString() 9 | private val distance: Double = step.distance() 10 | private val expectedTravelTime: Double = step.duration() 11 | 12 | fun toJsonObject(): JsonObject { 13 | val json = JsonObject() 14 | 15 | json.addProperty("instructions", instructions) 16 | json.addProperty("distance", distance) 17 | json.addProperty("expectedTravelTime", expectedTravelTime) 18 | 19 | return json 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ios/Classes/NavigationViewFactory.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import MapboxMaps 4 | import MapboxDirections 5 | import MapboxCoreNavigation 6 | import MapboxNavigation 7 | 8 | public class FlutterMapboxNavigationViewFactory : NSObject, FlutterPlatformViewFactory 9 | { 10 | let messenger: FlutterBinaryMessenger 11 | 12 | init(messenger: FlutterBinaryMessenger) { 13 | self.messenger = messenger 14 | } 15 | 16 | public func create(withFrame frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?) -> FlutterPlatformView { 17 | return FlutterMapboxNavigationView(messenger: self.messenger, frame: frame, viewId: viewId, args: args) 18 | } 19 | 20 | public func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol { 21 | return FlutterStandardMessageCodec.sharedInstance() 22 | } 23 | } -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /flutter_mapbox_navigation.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /linux/include/flutter_mapbox_navigation/flutter_mapbox_navigation_plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_PLUGIN_FLUTTER_MAPBOX_NAVIGATION_PLUGIN_H_ 2 | #define FLUTTER_PLUGIN_FLUTTER_MAPBOX_NAVIGATION_PLUGIN_H_ 3 | 4 | #include 5 | 6 | G_BEGIN_DECLS 7 | 8 | #ifdef FLUTTER_PLUGIN_IMPL 9 | #define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default"))) 10 | #else 11 | #define FLUTTER_PLUGIN_EXPORT 12 | #endif 13 | 14 | typedef struct _FlutterMapboxNavigationPlugin FlutterMapboxNavigationPlugin; 15 | typedef struct { 16 | GObjectClass parent_class; 17 | } FlutterMapboxNavigationPluginClass; 18 | 19 | FLUTTER_PLUGIN_EXPORT GType flutter_mapbox_navigation_plugin_get_type(); 20 | 21 | FLUTTER_PLUGIN_EXPORT void flutter_mapbox_navigation_plugin_register_with_registrar( 22 | FlPluginRegistrar* registrar); 23 | 24 | G_END_DECLS 25 | 26 | #endif // FLUTTER_PLUGIN_FLUTTER_MAPBOX_NAVIGATION_PLUGIN_H_ 27 | -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /ios/Classes/styles/Day.swift: -------------------------------------------------------------------------------- 1 | import MapboxMaps 2 | import MapboxNavigation 3 | import MapboxMaps 4 | 5 | class CustomDayStyle: DayStyle { 6 | 7 | required init() { 8 | super.init() 9 | initStyle() 10 | } 11 | 12 | init(url: String?){ 13 | super.init() 14 | initStyle() 15 | if(url != nil) 16 | { 17 | mapStyleURL = URL(string: url!) ?? URL(string: StyleURI.navigationDay.rawValue)! 18 | previewMapStyleURL = mapStyleURL 19 | } 20 | } 21 | 22 | func initStyle() 23 | { 24 | // Use a custom map style. 25 | mapStyleURL = URL(string: StyleURI.navigationDay.rawValue)! 26 | previewMapStyleURL = mapStyleURL 27 | 28 | // Specify that the style should be used during the day. 29 | styleType = .day 30 | } 31 | 32 | override func apply() { 33 | super.apply() 34 | // Begin styling the UI 35 | //BottomBannerView.appearance().backgroundColor = .orange 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /.github/workflows/linter.yml: -------------------------------------------------------------------------------- 1 | # This workflow executes several linters on changed files based on languages used in your code base whenever 2 | # you push a code or open a pull request. 3 | # 4 | # You can adjust the behavior by modifying this file. 5 | # For more information, see: 6 | # https://github.com/github/super-linter 7 | name: Lint Code Base 8 | 9 | on: 10 | push: 11 | branches: [ "master" ] 12 | pull_request: 13 | branches: [ "master" ] 14 | jobs: 15 | run-lint: 16 | runs-on: ubuntu-latest 17 | environment: dev 18 | steps: 19 | - name: Checkout code 20 | uses: actions/checkout@v3 21 | with: 22 | # Full git history is needed to get a proper list of changed files within `super-linter` 23 | fetch-depth: 0 24 | 25 | - name: Lint Code Base 26 | uses: github/super-linter@v4 27 | env: 28 | VALIDATE_ALL_CODEBASE: false 29 | DEFAULT_BRANCH: "master" 30 | GITHUB_TOKEN: ${{ secrets.MAPBOX_NAVIGATION_GITHUB_TOKEN }} 31 | -------------------------------------------------------------------------------- /ios/Classes/models/RouteLeg.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import MapboxDirections 3 | 4 | public class MapBoxRouteLeg : Codable 5 | { 6 | let profileIdentifier: String 7 | let name: String 8 | let distance: Double 9 | let expectedTravelTime: Double 10 | let source: Location 11 | let destination: Location 12 | var steps: [MapBoxRouteStep] = [] 13 | 14 | init(leg: RouteLeg) { 15 | profileIdentifier = leg.profileIdentifier.rawValue 16 | name = leg.name 17 | distance = leg.distance 18 | expectedTravelTime = leg.expectedTravelTime 19 | source = Location(name: leg.source?.name ?? "source", latitude: leg.source?.coordinate.latitude, longitude: leg.source?.coordinate.longitude) 20 | destination = Location(name: leg.destination?.name ?? "source", latitude: leg.destination?.coordinate.latitude, longitude: leg.destination?.coordinate.longitude) 21 | for step in leg.steps { 22 | steps.append(MapBoxRouteStep(step: step)) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/models/MapBoxEvents.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.models 2 | 3 | enum class MapBoxEvents(val value: String) { 4 | MAP_READY("map_ready"), 5 | ROUTE_BUILDING("route_building"), 6 | ROUTE_BUILT("route_built"), 7 | ROUTE_BUILD_FAILED("route_build_failed"), 8 | ROUTE_BUILD_CANCELLED("route_build_cancelled"), 9 | ROUTE_BUILD_NO_ROUTES_FOUND("route_build_no_routes_found"), 10 | PROGRESS_CHANGE("progress_change"), 11 | USER_OFF_ROUTE("user_off_route"), 12 | MILESTONE_EVENT("milestone_event"), 13 | NAVIGATION_RUNNING("navigation_running"), 14 | NAVIGATION_CANCELLED("navigation_cancelled"), 15 | NAVIGATION_FINISHED("navigation_finished"), 16 | FASTER_ROUTE_FOUND("faster_route_found"), 17 | SPEECH_ANNOUNCEMENT("speech_announcement"), 18 | BANNER_INSTRUCTION("banner_instruction"), 19 | ON_ARRIVAL("on_arrival"), 20 | FAILED_TO_REROUTE("failed_to_reroute"), 21 | REROUTE_ALONG("reroute_along"), 22 | ON_MAP_TAP("on_map_tap") 23 | } 24 | -------------------------------------------------------------------------------- /ios/Classes/styles/Night.swift: -------------------------------------------------------------------------------- 1 | import MapboxMaps 2 | import MapboxDirections 3 | import MapboxCoreNavigation 4 | import MapboxNavigation 5 | 6 | class CustomNightStyle: NightStyle { 7 | 8 | required init() { 9 | super.init() 10 | initStyle() 11 | } 12 | 13 | init(url: String?){ 14 | super.init() 15 | initStyle() 16 | if(url != nil) 17 | { 18 | mapStyleURL = URL(string: url!) ?? URL(string: StyleURI.navigationNight.rawValue)! 19 | previewMapStyleURL = mapStyleURL 20 | } 21 | } 22 | 23 | func initStyle() 24 | { 25 | // Use a custom map style. 26 | mapStyleURL = URL(string: StyleURI.navigationNight.rawValue)! 27 | previewMapStyleURL = mapStyleURL 28 | 29 | // Specify that the style should be used during the day. 30 | styleType = .night 31 | } 32 | 33 | override func apply() { 34 | super.apply() 35 | // Begin styling the UI 36 | //BottomBannerView.appearance().backgroundColor = .orange 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_mapbox_navigation_example/app.dart'; 10 | import 'package:flutter_test/flutter_test.dart'; 11 | 12 | void main() { 13 | testWidgets('Verify Platform version', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | await tester.pumpWidget(const SampleNavigationApp()); 16 | 17 | // Verify that platform version is retrieved. 18 | expect( 19 | find.byWidgetPredicate( 20 | (Widget widget) => widget is Text && 21 | widget.data!.startsWith('Running on:'), 22 | ), 23 | findsOneWidget, 24 | ); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /macos/flutter_mapbox_navigation.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_mapbox_navigation.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'flutter_mapbox_navigation' 7 | s.version = '0.0.1' 8 | s.summary = 'Add Turn By Turn Navigation to Your Flutter Application Using MapBox. Never leave your app when you need to navigate your users to a location.' 9 | s.description = <<-DESC 10 | Add Turn By Turn Navigation to Your Flutter Application Using MapBox. Never leave your app when you need to navigate your users to a location. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | 16 | s.source = { :path => '.' } 17 | s.source_files = 'Classes/**/*' 18 | s.dependency 'FlutterMacOS' 19 | 20 | s.platform = :osx, '10.11' 21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } 22 | s.swift_version = '5.0' 23 | end 24 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/models/Waypoint.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.models 2 | 3 | import com.google.gson.annotations.SerializedName 4 | import com.mapbox.geojson.Point 5 | import java.io.Serializable 6 | 7 | /** 8 | * A simple class to capture how most people will express a waypoint. 9 | */ 10 | data class Waypoint( 11 | @SerializedName("name") 12 | val name: String = "", 13 | @SerializedName("point") 14 | val point: Point, 15 | @SerializedName("isSilent") 16 | val isSilent: Boolean, 17 | ) : Serializable { 18 | constructor(name: String, longitude: Double, latitude: Double, isSilent: Boolean) : this( 19 | name, 20 | Point.fromLngLat(longitude, latitude), 21 | isSilent 22 | ) 23 | constructor(name: String, point: Point) : this(name, point, false) 24 | constructor(longitude: Double, latitude: Double) : this( 25 | "", 26 | Point.fromLngLat(longitude, latitude), 27 | false 28 | ) 29 | constructor(point: Point, isSilent: Boolean) : this("", point, isSilent) 30 | constructor(point: Point) : this("", point, true) 31 | } 32 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_mapbox_navigation_example", 3 | "short_name": "flutter_mapbox_navigation_example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Demonstrates how to use the flutter_mapbox_navigation plugin.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /lib/src/models/route_step.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: public_member_api_docs 2 | 3 | import 'package:flutter_mapbox_navigation/src/helpers.dart'; 4 | 5 | ///A RouteStep object represents a single distinct maneuver along a route and 6 | ///the approach to the next maneuver. The route step object corresponds to 7 | ///a single instruction the user must follow to complete a portion of the route. 8 | ///For example, a step might require the user to turn then follow a road. 9 | class RouteStep { 10 | RouteStep( 11 | this.name, 12 | this.instructions, 13 | this.distance, 14 | this.expectedTravelTime, 15 | ); 16 | 17 | RouteStep.fromJson(Map json) { 18 | name = json['name'] as String?; 19 | instructions = json['instructions'] as String?; 20 | distance = isNullOrZero(json['distance'] as num?) 21 | ? 0.0 22 | : (json['distance'] as num).toDouble(); 23 | expectedTravelTime = isNullOrZero(json['expectedTravelTime'] as num?) 24 | ? 0.0 25 | : (json['expectedTravelTime'] as num).toDouble(); 26 | } 27 | 28 | String? name; 29 | String? instructions; 30 | double? distance; 31 | double? expectedTravelTime; 32 | } 33 | -------------------------------------------------------------------------------- /example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /windows/flutter_mapbox_navigation_plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_PLUGIN_FLUTTER_MAPBOX_NAVIGATION_PLUGIN_H_ 2 | #define FLUTTER_PLUGIN_FLUTTER_MAPBOX_NAVIGATION_PLUGIN_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace flutter_mapbox_navigation { 10 | 11 | class FlutterMapboxNavigationPlugin : public flutter::Plugin { 12 | public: 13 | static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar); 14 | 15 | FlutterMapboxNavigationPlugin(); 16 | 17 | virtual ~FlutterMapboxNavigationPlugin(); 18 | 19 | // Disallow copy and assign. 20 | FlutterMapboxNavigationPlugin(const FlutterMapboxNavigationPlugin&) = delete; 21 | FlutterMapboxNavigationPlugin& operator=(const FlutterMapboxNavigationPlugin&) = delete; 22 | 23 | private: 24 | // Called when a method is called on this plugin's channel from Dart. 25 | void HandleMethodCall( 26 | const flutter::MethodCall &method_call, 27 | std::unique_ptr> result); 28 | }; 29 | 30 | } // namespace flutter_mapbox_navigation 31 | 32 | #endif // FLUTTER_PLUGIN_FLUTTER_MAPBOX_NAVIGATION_PLUGIN_H_ 33 | -------------------------------------------------------------------------------- /lib/src/flutter_mapbox_navigation_web.dart: -------------------------------------------------------------------------------- 1 | // In order to *not* need this ignore, consider extracting the "web" version 2 | // of your plugin as a separate package, instead of inlining it in the same 3 | // package as the core of your plugin. 4 | // ignore: avoid_web_libraries_in_flutter 5 | // ignore_for_file: public_member_api_docs 6 | 7 | // ignore: avoid_web_libraries_in_flutter 8 | import 'dart:html' as html show window; 9 | 10 | import 'package:flutter_mapbox_navigation/src/flutter_mapbox_navigation_platform_interface.dart'; 11 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; 12 | 13 | /// A web implementation of the FlutterMapboxNavigationPlatform of the 14 | /// FlutterMapboxNavigation plugin. 15 | class FlutterMapboxNavigationWeb extends FlutterMapboxNavigationPlatform { 16 | /// Constructs a FlutterMapboxNavigationWeb 17 | FlutterMapboxNavigationWeb(); 18 | 19 | static void registerWith(Registrar registrar) { 20 | FlutterMapboxNavigationPlatform.instance = FlutterMapboxNavigationWeb(); 21 | } 22 | 23 | /// Returns a [String] containing the version of the platform. 24 | @override 25 | Future getPlatformVersion() async { 26 | final version = html.window.navigator.userAgent; 27 | return version; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_mapbox_navigation 2 | description: > 3 | Add Turn By Turn Navigation to Your Flutter Application Using MapBox. 4 | Never leave your app when you need to navigate your users to a location. 5 | version: 0.2.2 6 | homepage: "https://www.eopeter.com" 7 | repository: "https://github.com/eopeter/flutter_mapbox_navigation" 8 | 9 | environment: 10 | sdk: '>=2.19.4 <4.0.0' 11 | flutter: ">=2.5.0" 12 | 13 | dependencies: 14 | flutter: 15 | sdk: flutter 16 | flutter_web_plugins: 17 | sdk: flutter 18 | plugin_platform_interface: ^2.0.2 19 | very_good_analysis: ^5.0.0+1 20 | 21 | dev_dependencies: 22 | flutter_lints: ^2.0.0 23 | flutter_test: 24 | sdk: flutter 25 | 26 | flutter: 27 | plugin: 28 | platforms: 29 | android: 30 | package: com.eopeter.fluttermapboxnavigation 31 | pluginClass: FlutterMapboxNavigationPlugin 32 | ios: 33 | pluginClass: FlutterMapboxNavigationPlugin 34 | # linux: 35 | # pluginClass: FlutterMapboxNavigationPlugin 36 | # macos: 37 | # pluginClass: FlutterMapboxNavigationPlugin 38 | # windows: 39 | # pluginClass: FlutterMapboxNavigationPluginCApi 40 | # web: 41 | # pluginClass: FlutterMapboxNavigationWeb 42 | # fileName: flutter_mapbox_navigation_web.dart 43 | -------------------------------------------------------------------------------- /ios/flutter_mapbox_navigation.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_mapbox_navigation.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'flutter_mapbox_navigation' 7 | s.version = '0.2.2' 8 | s.summary = 'Add Turn By Turn Navigation to Your Flutter Application Using MapBox. Never leave your app when you need to navigate your users to a location.' 9 | s.description = <<-DESC 10 | Add Turn By Turn Navigation to Your Flutter Application Using MapBox. Never leave your app when you need to navigate your users to a location. 11 | DESC 12 | s.homepage = 'https://eopeter.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Emmanuel Peter Oche' => 'eopeter@gmail.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | s.dependency 'MapboxCoreNavigation', '~> 2.11' 19 | s.dependency 'MapboxNavigation', '~> 2.11' 20 | s.platform = :ios, '12.0' 21 | 22 | # Flutter.framework does not contain a i386 slice. 23 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } 24 | s.swift_version = '5.0' 25 | end 26 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"flutter_mapbox_navigation_example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /lib/src/models/route_event.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutter_mapbox_navigation/flutter_mapbox_navigation.dart'; 5 | 6 | /// Represents an event sent by the navigation service 7 | class RouteEvent { 8 | /// Constructor 9 | RouteEvent({ 10 | this.eventType, 11 | this.data, 12 | }); 13 | 14 | /// Creates [RouteEvent] object from json 15 | RouteEvent.fromJson(Map json) { 16 | try { 17 | eventType = MapBoxEvent.values 18 | .firstWhere((e) => e.toString().split('.').last == json['eventType']); 19 | } catch (e) { 20 | // TODO handle the error 21 | } 22 | 23 | final dataJson = json['data']; 24 | if (eventType == MapBoxEvent.progress_change) { 25 | data = RouteProgressEvent.fromJson(dataJson as Map); 26 | } else if (eventType == MapBoxEvent.navigation_finished && 27 | (dataJson as String).isNotEmpty) { 28 | data = 29 | MapBoxFeedback.fromJson(jsonDecode(dataJson) as Map); 30 | } else if (eventType == MapBoxEvent.on_map_tap) { 31 | final json = 32 | Platform.isAndroid ? dataJson : jsonDecode(dataJson as String); 33 | data = WayPoint.fromJson(json as Map); 34 | } else { 35 | data = jsonEncode(dataJson); 36 | } 37 | } 38 | 39 | /// Route event type 40 | MapBoxEvent? eventType; 41 | 42 | /// optional data related to route event 43 | dynamic data; 44 | } 45 | -------------------------------------------------------------------------------- /example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/src/models/way_point.dart: -------------------------------------------------------------------------------- 1 | ///A `WayPoint` object indicates a location along a route. 2 | ///It may be the route’s origin or destination, or it may be another location 3 | ///that the route visits. A waypoint object indicates the location’s geographic 4 | ///location along with other optional information, such as a name or 5 | ///the user’s direction approaching the waypoint. 6 | class WayPoint { 7 | ///Constructor 8 | WayPoint({ 9 | required this.name, 10 | required this.latitude, 11 | required this.longitude, 12 | this.isSilent = false, 13 | }); 14 | 15 | /// create [WayPoint] from a json 16 | WayPoint.fromJson(Map json) { 17 | name = json['name'] as String?; 18 | latitude = (json['latitude'] is String) 19 | ? double.tryParse(json['latitude'] as String) 20 | : json['latitude'] as double?; 21 | longitude = (json['longitude'] is String) 22 | ? double.tryParse(json['longitude'] as String) 23 | : json['longitude'] as double?; 24 | 25 | if (json['isSilent'] == null) { 26 | isSilent = false; 27 | } else { 28 | isSilent = json['isSilent'] as bool; 29 | } 30 | } 31 | 32 | /// Waypoint [name] 33 | String? name; 34 | 35 | /// Waypoint latitude 36 | double? latitude; 37 | 38 | /// Waypoint longitude 39 | double? longitude; 40 | 41 | /// Waypoint property isSilent 42 | bool? isSilent; 43 | 44 | @override 45 | String toString() { 46 | return 'WayPoint{latitude: $latitude, longitude: $longitude}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /android/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 16 | 17 | 21 | 22 | 29 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/models/MapBoxRouteLeg.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.models 2 | 3 | import com.google.gson.JsonArray 4 | import com.google.gson.JsonObject 5 | import com.mapbox.api.directions.v5.models.RouteLeg 6 | 7 | class MapBoxRouteLeg { 8 | 9 | val profileIdentifier: String? = null 10 | val name: String? = null 11 | private var distance: Double? 12 | private var expectedTravelTime: Double? 13 | val source: MapBoxLocation = MapBoxLocation("", 0.0, 0.0) 14 | val destination: MapBoxLocation = MapBoxLocation("", 0.0, 0.0) 15 | private var steps: MutableList = mutableListOf() 16 | 17 | constructor(leg: RouteLeg) { 18 | distance = leg.distance() 19 | expectedTravelTime = leg.duration() 20 | 21 | for (step in leg.steps()!!) { 22 | steps.add(MapBoxRouteStep(step)) 23 | } 24 | } 25 | 26 | fun toJsonObject(): JsonObject { 27 | val json = JsonObject() 28 | 29 | if (distance != null) { 30 | json.addProperty("distance", distance) 31 | } 32 | 33 | if (expectedTravelTime != null) { 34 | json.addProperty("expectedTravelTime", expectedTravelTime) 35 | } 36 | 37 | if (steps.isNotEmpty()) { 38 | val ls = JsonArray() 39 | 40 | for (step in steps) { 41 | ls.add(step.toJsonObject()) 42 | } 43 | 44 | json.add("steps", ls) 45 | } 46 | 47 | return json 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/activity/NavigationLauncher.java: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.activity; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | 6 | import com.eopeter.fluttermapboxnavigation.models.Waypoint; 7 | 8 | import java.io.Serializable; 9 | import java.util.List; 10 | 11 | public class NavigationLauncher { 12 | public static final String KEY_ADD_WAYPOINTS = "com.my.mapbox.broadcast.ADD_WAYPOINTS"; 13 | public static final String KEY_STOP_NAVIGATION = "com.my.mapbox.broadcast.STOP_NAVIGATION"; 14 | public static void startNavigation(Activity activity, List wayPoints) { 15 | Intent navigationIntent = new Intent(activity, NavigationActivity.class); 16 | navigationIntent.putExtra("waypoints", (Serializable) wayPoints); 17 | activity.startActivity(navigationIntent); 18 | } 19 | 20 | public static void addWayPoints(Activity activity, List wayPoints) { 21 | Intent navigationIntent = new Intent(activity, NavigationActivity.class); 22 | navigationIntent.setAction(KEY_ADD_WAYPOINTS); 23 | navigationIntent.putExtra("isAddingWayPoints", true); 24 | navigationIntent.putExtra("waypoints", (Serializable) wayPoints); 25 | activity.sendBroadcast(navigationIntent); 26 | } 27 | 28 | public static void stopNavigation(Activity activity) { 29 | Intent stopIntent = new Intent(); 30 | stopIntent.setAction(KEY_STOP_NAVIGATION); 31 | activity.sendBroadcast(stopIntent); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /ios/Classes/FreeDriveViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FreeDriveViewController.swift 3 | // flutter_mapbox_navigation 4 | // 5 | // Created by Emmanuel Oche on 5/25/23. 6 | // 7 | 8 | import UIKit 9 | import MapboxNavigation 10 | import MapboxCoreNavigation 11 | import MapboxMaps 12 | 13 | public class FreeDriveViewController : UIViewController { 14 | 15 | private lazy var navigationMapView = NavigationMapView(frame: view.bounds) 16 | private let passiveLocationManager = PassiveLocationManager() 17 | private lazy var passiveLocationProvider = PassiveLocationProvider(locationManager: passiveLocationManager) 18 | 19 | public override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | setupNavigationMapView() 23 | let locationProvider: LocationProvider = passiveLocationProvider 24 | navigationMapView.mapView.location.overrideLocationProvider(with: locationProvider) 25 | passiveLocationProvider.startUpdatingLocation() 26 | } 27 | 28 | private func setupNavigationMapView() { 29 | navigationMapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 30 | navigationMapView.userLocationStyle = .puck2D() 31 | 32 | let navigationViewportDataSource = NavigationViewportDataSource(navigationMapView.mapView) 33 | navigationViewportDataSource.options.followingCameraOptions.zoomUpdatesAllowed = false 34 | navigationViewportDataSource.followingMobileCamera.zoom = 17.0 35 | navigationMapView.navigationCamera.viewportDataSource = navigationViewportDataSource 36 | 37 | view.addSubview(navigationMapView) 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/factory/EmbeddedNavigationViewFactory.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.factory 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import android.view.LayoutInflater 6 | import com.eopeter.fluttermapboxnavigation.R 7 | import com.eopeter.fluttermapboxnavigation.databinding.NavigationActivityBinding 8 | import com.eopeter.fluttermapboxnavigation.models.views.EmbeddedNavigationMapView 9 | import com.eopeter.fluttermapboxnavigation.utilities.PluginUtilities 10 | import io.flutter.plugin.common.BinaryMessenger 11 | import io.flutter.plugin.common.StandardMessageCodec 12 | import io.flutter.plugin.platform.PlatformView 13 | import io.flutter.plugin.platform.PlatformViewFactory 14 | 15 | class EmbeddedNavigationViewFactory( 16 | private val messenger: BinaryMessenger, 17 | private val activity: Activity 18 | ) : PlatformViewFactory(StandardMessageCodec.INSTANCE) { 19 | override fun create(context: Context, viewId: Int, args: Any?): PlatformView { 20 | val inflater = LayoutInflater.from(context) 21 | val binding = NavigationActivityBinding.inflate(inflater) 22 | val accessToken = PluginUtilities.getResourceFromContext(context, "mapbox_access_token") 23 | val view = EmbeddedNavigationMapView( 24 | context, 25 | activity, 26 | binding, 27 | messenger, 28 | viewId, 29 | args, 30 | accessToken 31 | ) 32 | 33 | view.initialize() 34 | 35 | activity.setTheme(R.style.Theme_AppCompat_NoActionBar) 36 | 37 | return view 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ios/Classes/models/RouteProgressEvent.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import MapboxDirections 3 | import MapboxNavigation 4 | import MapboxCoreNavigation 5 | 6 | public class MapBoxRouteProgressEvent : Codable 7 | { 8 | let arrived: Bool 9 | let distance: Double 10 | let duration: Double 11 | let distanceTraveled: Double 12 | let currentLegDistanceTraveled: Double 13 | let currentLegDistanceRemaining: Double 14 | let currentStepInstruction: String 15 | let legIndex: Int 16 | let stepIndex: Int 17 | let currentLeg: MapBoxRouteLeg 18 | var priorLeg: MapBoxRouteLeg? = nil 19 | var remainingLegs: [MapBoxRouteLeg] = [] 20 | 21 | init(progress: RouteProgress) { 22 | 23 | arrived = progress.isFinalLeg && progress.currentLegProgress.userHasArrivedAtWaypoint 24 | distance = progress.distanceRemaining 25 | distanceTraveled = progress.distanceTraveled 26 | duration = progress.durationRemaining 27 | legIndex = progress.legIndex 28 | stepIndex = progress.currentLegProgress.stepIndex 29 | 30 | currentLeg = MapBoxRouteLeg(leg: progress.currentLeg) 31 | 32 | if(progress.priorLeg != nil) 33 | { 34 | priorLeg = MapBoxRouteLeg(leg: progress.priorLeg!) 35 | } 36 | 37 | for leg in progress.remainingLegs 38 | { 39 | remainingLegs.append(MapBoxRouteLeg(leg: leg)) 40 | } 41 | 42 | currentLegDistanceTraveled = progress.currentLegProgress.distanceTraveled 43 | currentLegDistanceRemaining = progress.currentLegProgress.distanceRemaining 44 | currentStepInstruction = progress.currentLegProgress.currentStep.description 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 8 | channel: stable 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 17 | base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 18 | - platform: android 19 | create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 20 | base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 21 | - platform: ios 22 | create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 23 | base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 24 | - platform: linux 25 | create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 26 | base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 27 | - platform: macos 28 | create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 29 | base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 30 | - platform: web 31 | create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 32 | base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 33 | - platform: windows 34 | create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 35 | base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/utilities/CustomInfoPanelEndNavButtonBinder.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.utilities 2 | 3 | import android.app.Activity 4 | import android.view.ViewGroup 5 | import com.eopeter.fluttermapboxnavigation.activity.NavigationLauncher 6 | import com.eopeter.fluttermapboxnavigation.models.MapBoxEvents 7 | import com.mapbox.navigation.core.MapboxNavigation 8 | import com.mapbox.navigation.core.lifecycle.MapboxNavigationObserver 9 | import com.mapbox.navigation.dropin.R 10 | import com.mapbox.navigation.dropin.internal.extensions.updateMargins 11 | import com.mapbox.navigation.ui.base.lifecycle.UIBinder 12 | import com.mapbox.navigation.ui.base.lifecycle.UIComponent 13 | import com.mapbox.navigation.ui.base.view.MapboxExtendableButton 14 | 15 | class CustomInfoPanelEndNavButtonBinder( 16 | val activity: Activity 17 | ) : UIBinder { 18 | override fun bind(viewGroup: ViewGroup): MapboxNavigationObserver { 19 | val button = MapboxExtendableButton( 20 | viewGroup.context, 21 | null, 22 | R.style.DropInStyleExitButton 23 | ) 24 | button.iconImage.setImageResource(R.drawable.mapbox_ic_stop_navigation) 25 | viewGroup.removeAllViews() 26 | viewGroup.addView(button) 27 | button.updateMargins( 28 | right = button.resources.getDimensionPixelSize(R.dimen.mapbox_infoPanel_paddingEnd) 29 | ) 30 | 31 | return object : UIComponent() { 32 | override fun onAttached(mapboxNavigation: MapboxNavigation) { 33 | super.onAttached(mapboxNavigation) 34 | button.setOnClickListener { 35 | mapboxNavigation.stopTripSession() 36 | PluginUtilities.sendEvent(MapBoxEvents.NAVIGATION_CANCELLED) 37 | activity.finish() 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The Flutter tooling requires that developers have CMake 3.10 or later 2 | # installed. You should not increase this version, as doing so will cause 3 | # the plugin to fail to compile for some customers of the plugin. 4 | cmake_minimum_required(VERSION 3.10) 5 | 6 | # Project-level configuration. 7 | set(PROJECT_NAME "flutter_mapbox_navigation") 8 | project(${PROJECT_NAME} LANGUAGES CXX) 9 | 10 | # This value is used when generating builds using this plugin, so it must 11 | # not be changed. 12 | set(PLUGIN_NAME "flutter_mapbox_navigation_plugin") 13 | 14 | # Define the plugin library target. Its name must not be changed (see comment 15 | # on PLUGIN_NAME above). 16 | # 17 | # Any new source files that you add to the plugin should be added here. 18 | add_library(${PLUGIN_NAME} SHARED 19 | "flutter_mapbox_navigation_plugin.cc" 20 | ) 21 | 22 | # Apply a standard set of build settings that are configured in the 23 | # application-level CMakeLists.txt. This can be removed for plugins that want 24 | # full control over build settings. 25 | apply_standard_settings(${PLUGIN_NAME}) 26 | 27 | # Symbols are hidden by default to reduce the chance of accidental conflicts 28 | # between plugins. This should not be removed; any symbols that should be 29 | # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro. 30 | set_target_properties(${PLUGIN_NAME} PROPERTIES 31 | CXX_VISIBILITY_PRESET hidden) 32 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) 33 | 34 | # Source include directories and library dependencies. Add any plugin-specific 35 | # dependencies here. 36 | target_include_directories(${PLUGIN_NAME} INTERFACE 37 | "${CMAKE_CURRENT_SOURCE_DIR}/include") 38 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter) 39 | target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK) 40 | 41 | # List of absolute paths to libraries that should be bundled with the plugin. 42 | # This list could contain prebuilt libraries, or libraries created by an 43 | # external build triggered from this build file. 44 | set(flutter_mapbox_navigation_bundled_libraries 45 | "" 46 | PARENT_SCOPE 47 | ) 48 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | return true; 35 | } 36 | 37 | void FlutterWindow::OnDestroy() { 38 | if (flutter_controller_) { 39 | flutter_controller_ = nullptr; 40 | } 41 | 42 | Win32Window::OnDestroy(); 43 | } 44 | 45 | LRESULT 46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 47 | WPARAM const wparam, 48 | LPARAM const lparam) noexcept { 49 | // Give Flutter, including plugins, an opportunity to handle window messages. 50 | if (flutter_controller_) { 51 | std::optional result = 52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 53 | lparam); 54 | if (result) { 55 | return *result; 56 | } 57 | } 58 | 59 | switch (message) { 60 | case WM_FONTCHANGE: 61 | flutter_controller_->engine()->ReloadSystemFonts(); 62 | break; 63 | } 64 | 65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 66 | } 67 | -------------------------------------------------------------------------------- /lib/src/models/route_leg.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: public_member_api_docs 2 | 3 | import 'package:flutter_mapbox_navigation/src/helpers.dart'; 4 | import 'package:flutter_mapbox_navigation/src/models/route_step.dart'; 5 | import 'package:flutter_mapbox_navigation/src/models/way_point.dart'; 6 | 7 | ///A RouteLeg object defines a single leg of a route between two waypoints. 8 | ///If the overall route has only two waypoints, it has a single 9 | ///RouteLeg object that covers the entire route. 10 | ///The route leg object includes information about the leg, such as its name, 11 | ///distance, and expected travel time. 12 | ///Depending on the criteria used to calculate the route, the route leg object 13 | ///may also include detailed turn-by-turn instructions. 14 | class RouteLeg { 15 | RouteLeg( 16 | this.profileIdentifier, 17 | this.name, 18 | this.distance, 19 | this.expectedTravelTime, 20 | this.source, 21 | this.destination, 22 | this.steps, 23 | ); 24 | 25 | RouteLeg.fromJson(Map json) { 26 | profileIdentifier = json['profileIdentifier'] as String?; 27 | name = json['name'] as String?; 28 | distance = isNullOrZero(json['distance'] as num?) 29 | ? 0.0 30 | : (json['distance'] as num).toDouble(); 31 | expectedTravelTime = isNullOrZero(json['expectedTravelTime'] as num?) 32 | ? 0.0 33 | : (json['expectedTravelTime'] as num).toDouble(); 34 | source = json['source'] == null 35 | ? null 36 | : WayPoint.fromJson(json['source'] as Map); 37 | destination = json['destination'] == null 38 | ? null 39 | : WayPoint.fromJson(json['destination'] as Map); 40 | steps = (json['steps'] as List?) 41 | ?.map( 42 | (e) => 43 | e == null ? null : RouteStep.fromJson(e as Map), 44 | ) 45 | .cast() 46 | .toList(); 47 | } 48 | 49 | String? profileIdentifier; 50 | String? name; 51 | double? distance; 52 | double? expectedTravelTime; 53 | WayPoint? source; 54 | WayPoint? destination; 55 | List? steps; 56 | } 57 | -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | flutter_mapbox_navigation_example 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /windows/flutter_mapbox_navigation_plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_mapbox_navigation_plugin.h" 2 | 3 | // This must be included before many other Windows headers. 4 | #include 5 | 6 | // For getPlatformVersion; remove unless needed for your plugin implementation. 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | namespace flutter_mapbox_navigation { 17 | 18 | // static 19 | void FlutterMapboxNavigationPlugin::RegisterWithRegistrar( 20 | flutter::PluginRegistrarWindows *registrar) { 21 | auto channel = 22 | std::make_unique>( 23 | registrar->messenger(), "flutter_mapbox_navigation", 24 | &flutter::StandardMethodCodec::GetInstance()); 25 | 26 | auto plugin = std::make_unique(); 27 | 28 | channel->SetMethodCallHandler( 29 | [plugin_pointer = plugin.get()](const auto &call, auto result) { 30 | plugin_pointer->HandleMethodCall(call, std::move(result)); 31 | }); 32 | 33 | registrar->AddPlugin(std::move(plugin)); 34 | } 35 | 36 | FlutterMapboxNavigationPlugin::FlutterMapboxNavigationPlugin() {} 37 | 38 | FlutterMapboxNavigationPlugin::~FlutterMapboxNavigationPlugin() {} 39 | 40 | void FlutterMapboxNavigationPlugin::HandleMethodCall( 41 | const flutter::MethodCall &method_call, 42 | std::unique_ptr> result) { 43 | if (method_call.method_name().compare("getPlatformVersion") == 0) { 44 | std::ostringstream version_stream; 45 | version_stream << "Windows "; 46 | if (IsWindows10OrGreater()) { 47 | version_stream << "10+"; 48 | } else if (IsWindows8OrGreater()) { 49 | version_stream << "8"; 50 | } else if (IsWindows7OrGreater()) { 51 | version_stream << "7"; 52 | } 53 | result->Success(flutter::EncodableValue(version_stream.str())); 54 | } else { 55 | result->NotImplemented(); 56 | } 57 | } 58 | 59 | } // namespace flutter_mapbox_navigation 60 | -------------------------------------------------------------------------------- /test/flutter_mapbox_navigation_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:flutter_mapbox_navigation/flutter_mapbox_navigation.dart'; 3 | import 'package:flutter_mapbox_navigation/src/flutter_mapbox_navigation_method_channel.dart'; 4 | import 'package:flutter_mapbox_navigation/src/flutter_mapbox_navigation_platform_interface.dart'; 5 | import 'package:flutter_test/flutter_test.dart'; 6 | import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 7 | 8 | class MockFlutterMapboxNavigationPlatform 9 | with MockPlatformInterfaceMixin 10 | implements FlutterMapboxNavigationPlatform { 11 | @override 12 | Future getPlatformVersion() => Future.value('42'); 13 | 14 | @override 15 | Future addWayPoints({required List wayPoints}) => 16 | Future.value(''); 17 | 18 | @override 19 | Future enableOfflineRouting() => Future.value(true); 20 | 21 | @override 22 | Future finishNavigation() => Future.value(true); 23 | 24 | @override 25 | Future getDistanceRemaining() => Future.value(3.5); 26 | 27 | @override 28 | Future getDurationRemaining() => Future.value(50); 29 | 30 | @override 31 | Future startFreeDrive(MapBoxOptions options) => Future.value(true); 32 | 33 | @override 34 | Future startNavigation( 35 | List wayPoints, 36 | MapBoxOptions options, 37 | ) => 38 | Future.value(); 39 | 40 | @override 41 | Future registerRouteEventListener( 42 | ValueSetter listener, 43 | ) => 44 | Future.value(); 45 | } 46 | 47 | void main() { 48 | final initialPlatform = FlutterMapboxNavigationPlatform.instance; 49 | 50 | test('$MethodChannelFlutterMapboxNavigation is the default instance', () { 51 | expect( 52 | initialPlatform, 53 | isInstanceOf(), 54 | ); 55 | }); 56 | 57 | test('getPlatformVersion', () async { 58 | final flutterMapboxNavigationPlugin = MapBoxNavigation(); 59 | final fakePlatform = MockFlutterMapboxNavigationPlatform(); 60 | FlutterMapboxNavigationPlatform.instance = fakePlatform; 61 | 62 | expect(await flutterMapboxNavigationPlugin.getPlatformVersion(), '42'); 63 | }); 64 | } 65 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/models/WaypointSet.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.models 2 | 3 | import com.mapbox.api.directions.v5.models.RouteOptions 4 | import com.mapbox.geojson.Point 5 | 6 | /** 7 | * Helper class that that does 2 things: 8 | * 1. It stores waypoints 9 | * 2. Converts the stored waypoints to the [RouteOptions] params 10 | */ 11 | class WaypointSet { 12 | 13 | private val waypoints = mutableListOf() 14 | 15 | val isEmpty get() = waypoints.isEmpty() 16 | 17 | fun add(waypoint: Waypoint) { 18 | waypoints.add(waypoint) 19 | } 20 | 21 | fun clear() { 22 | waypoints.clear() 23 | } 24 | 25 | /*** 26 | * Silent waypoint isn't really a waypoint. 27 | * It's just a coordinate that used to build a route. 28 | * That's why to make a waypoint silent we exclude its index from the waypointsIndices. 29 | */ 30 | fun waypointsIndices(): List { 31 | return waypoints.mapIndexedNotNull { index, _ -> 32 | if (waypoints.isSilentWaypoint(index)) { 33 | null 34 | } else index 35 | } 36 | } 37 | 38 | /** 39 | * Returns names for added waypoints. 40 | * Silent waypoint can't have a name unless they're converted to regular because of position. 41 | * First and last waypoint can't be silent. 42 | */ 43 | fun waypointsNames(): List = waypoints 44 | // silent waypoints can't have a name 45 | .filterIndexed { index, _ -> 46 | !waypoints.isSilentWaypoint(index) 47 | } 48 | .map { 49 | it.name 50 | } 51 | 52 | fun coordinatesList(): List { 53 | return waypoints.map { it.point } 54 | } 55 | 56 | private fun List.isSilentWaypoint(index: Int) = 57 | //this[index].type == WaypointType.Silent && canWaypointBeSilent(index) 58 | this[index].isSilent && canWaypointBeSilent(index) 59 | 60 | // the first and the last waypoint can't be silent 61 | private fun List.canWaypointBeSilent(index: Int): Boolean { 62 | val isLastWaypoint = index == this.size - 1 63 | val isFirstWaypoint = index == 0 64 | return !isLastWaypoint && !isFirstWaypoint 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The Flutter tooling requires that developers have a version of Visual Studio 2 | # installed that includes CMake 3.14 or later. You should not increase this 3 | # version, as doing so will cause the plugin to fail to compile for some 4 | # customers of the plugin. 5 | cmake_minimum_required(VERSION 3.14) 6 | 7 | # Project-level configuration. 8 | set(PROJECT_NAME "flutter_mapbox_navigation") 9 | project(${PROJECT_NAME} LANGUAGES CXX) 10 | 11 | # This value is used when generating builds using this plugin, so it must 12 | # not be changed 13 | set(PLUGIN_NAME "flutter_mapbox_navigation_plugin") 14 | 15 | # Any new source files that you add to the plugin should be added here. 16 | list(APPEND PLUGIN_SOURCES 17 | "flutter_mapbox_navigation_plugin.cpp" 18 | "flutter_mapbox_navigation_plugin.h" 19 | ) 20 | 21 | # Define the plugin library target. Its name must not be changed (see comment 22 | # on PLUGIN_NAME above). 23 | add_library(${PLUGIN_NAME} SHARED 24 | "include/flutter_mapbox_navigation/flutter_mapbox_navigation_plugin_c_api.h" 25 | "flutter_mapbox_navigation_plugin_c_api.cpp" 26 | ${PLUGIN_SOURCES} 27 | ) 28 | 29 | # Apply a standard set of build settings that are configured in the 30 | # application-level CMakeLists.txt. This can be removed for plugins that want 31 | # full control over build settings. 32 | apply_standard_settings(${PLUGIN_NAME}) 33 | 34 | # Symbols are hidden by default to reduce the chance of accidental conflicts 35 | # between plugins. This should not be removed; any symbols that should be 36 | # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro. 37 | set_target_properties(${PLUGIN_NAME} PROPERTIES 38 | CXX_VISIBILITY_PRESET hidden) 39 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) 40 | 41 | # Source include directories and library dependencies. Add any plugin-specific 42 | # dependencies here. 43 | target_include_directories(${PLUGIN_NAME} INTERFACE 44 | "${CMAKE_CURRENT_SOURCE_DIR}/include") 45 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) 46 | 47 | # List of absolute paths to libraries that should be bundled with the plugin. 48 | # This list could contain prebuilt libraries, or libraries created by an 49 | # external build triggered from this build file. 50 | set(flutter_mapbox_navigation_bundled_libraries 51 | "" 52 | PARENT_SCOPE 53 | ) 54 | -------------------------------------------------------------------------------- /ios/Classes/FlutterMapboxNavigationPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import MapboxMaps 4 | import MapboxDirections 5 | import MapboxCoreNavigation 6 | import MapboxNavigation 7 | 8 | public class FlutterMapboxNavigationPlugin: NavigationFactory, FlutterPlugin { 9 | public static func register(with registrar: FlutterPluginRegistrar) { 10 | let channel = FlutterMethodChannel(name: "flutter_mapbox_navigation", binaryMessenger: registrar.messenger()) 11 | let eventChannel = FlutterEventChannel(name: "flutter_mapbox_navigation/events", binaryMessenger: registrar.messenger()) 12 | let instance = FlutterMapboxNavigationPlugin() 13 | registrar.addMethodCallDelegate(instance, channel: channel) 14 | 15 | eventChannel.setStreamHandler(instance) 16 | 17 | let viewFactory = FlutterMapboxNavigationViewFactory(messenger: registrar.messenger()) 18 | registrar.register(viewFactory, withId: "FlutterMapboxNavigationView") 19 | 20 | } 21 | 22 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 23 | 24 | let arguments = call.arguments as? NSDictionary 25 | 26 | if(call.method == "getPlatformVersion") 27 | { 28 | result("iOS " + UIDevice.current.systemVersion) 29 | } 30 | else if(call.method == "getDistanceRemaining") 31 | { 32 | result(_distanceRemaining) 33 | } 34 | else if(call.method == "getDurationRemaining") 35 | { 36 | result(_durationRemaining) 37 | } 38 | else if(call.method == "startFreeDrive") 39 | { 40 | startFreeDrive(arguments: arguments, result: result) 41 | } 42 | else if(call.method == "startNavigation") 43 | { 44 | startNavigation(arguments: arguments, result: result) 45 | } 46 | else if(call.method == "addWayPoints") 47 | { 48 | addWayPoints(arguments: arguments, result: result) 49 | } 50 | else if(call.method == "finishNavigation") 51 | { 52 | endNavigation(result: result) 53 | } 54 | else if(call.method == "enableOfflineRouting") 55 | { 56 | downloadOfflineRoute(arguments: arguments, flutterResult: result) 57 | } 58 | else 59 | { 60 | result("Method is Not Implemented"); 61 | } 62 | 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | MapBox Nav 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_mapbox_navigation_example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | MBXAccessToken 28 | MAPBOX_ACCESS_TOKEN_HERE 29 | MGLMapboxMetricsEnabledSettingShownInApp 30 | YES 31 | NSLocationWhenInUseUsageDescription 32 | Shows your location on the map and helps improve the map 33 | UIBackgroundModes 34 | 35 | audio 36 | location 37 | remote-notification 38 | 39 | UILaunchStoryboardName 40 | LaunchScreen 41 | UIMainStoryboardFile 42 | Main 43 | UISupportedInterfaceOrientations 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | UISupportedInterfaceOrientations~ipad 50 | 51 | UIInterfaceOrientationPortrait 52 | UIInterfaceOrientationPortraitUpsideDown 53 | UIInterfaceOrientationLandscapeLeft 54 | UIInterfaceOrientationLandscapeRight 55 | 56 | UIViewControllerBasedStatusBarAppearance 57 | 58 | CADisableMinimumFrameDurationOnPhone 59 | 60 | UIApplicationSupportsIndirectInputEvents 61 | 62 | io.flutter.embedded_views_preview 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 33 30 | ndkVersion flutter.ndkVersion 31 | 32 | sourceSets { 33 | main.java.srcDirs += 'src/main/kotlin' 34 | } 35 | 36 | 37 | compileOptions { 38 | sourceCompatibility JavaVersion.VERSION_1_8 39 | targetCompatibility JavaVersion.VERSION_1_8 40 | } 41 | 42 | kotlinOptions { 43 | jvmTarget = '1.8' 44 | } 45 | 46 | defaultConfig { 47 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 48 | applicationId "com.eopeter.fluttermapboxnavigationexample" 49 | // You can update the following values to match your application needs. 50 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 51 | minSdkVersion 21 52 | targetSdkVersion 33 53 | versionCode flutterVersionCode.toInteger() 54 | versionName flutterVersionName 55 | } 56 | 57 | buildTypes { 58 | release { 59 | // TODO: Add your own signing config for the release build. 60 | // Signing with the debug keys for now, so `flutter run --release` works. 61 | signingConfig signingConfigs.debug 62 | } 63 | } 64 | lint { 65 | disable 'InvalidPackage' 66 | } 67 | namespace 'com.eopeter.fluttermapboxnavigationexample' 68 | } 69 | 70 | flutter { 71 | source '../..' 72 | } 73 | 74 | dependencies { 75 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 76 | implementation platform("org.jetbrains.kotlin:kotlin-bom:1.8.0") 77 | } 78 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_mapbox_navigation (0.2.0): 4 | - Flutter 5 | - MapboxCoreNavigation (~> 2.11) 6 | - MapboxNavigation (~> 2.11) 7 | - MapboxCommon (23.3.2) 8 | - MapboxCoreMaps (10.11.1): 9 | - MapboxCommon (~> 23.3) 10 | - MapboxCoreNavigation (2.11.0): 11 | - MapboxDirections (~> 2.10.0) 12 | - MapboxMobileEvents (~> 1.0) 13 | - MapboxNavigationNative (~> 126.0.1) 14 | - MapboxDirections (2.10.0): 15 | - Polyline (~> 5.0) 16 | - Turf (~> 2.6.1) 17 | - MapboxMaps (10.11.1): 18 | - MapboxCommon (= 23.3.2) 19 | - MapboxCoreMaps (= 10.11.1) 20 | - MapboxMobileEvents (= 1.0.10) 21 | - Turf (~> 2.0) 22 | - MapboxMobileEvents (1.0.10) 23 | - MapboxNavigation (2.11.0): 24 | - MapboxCoreNavigation (= 2.11.0) 25 | - MapboxMaps (~> 10.11.1) 26 | - MapboxMobileEvents (~> 1.0) 27 | - MapboxSpeech (~> 2.0) 28 | - Solar-dev (~> 3.0) 29 | - MapboxNavigationNative (126.0.3): 30 | - MapboxCommon (~> 23.3) 31 | - MapboxSpeech (2.1.1) 32 | - Polyline (5.1.0) 33 | - Solar-dev (3.0.1) 34 | - Turf (2.6.1) 35 | 36 | DEPENDENCIES: 37 | - Flutter (from `Flutter`) 38 | - flutter_mapbox_navigation (from `.symlinks/plugins/flutter_mapbox_navigation/ios`) 39 | 40 | SPEC REPOS: 41 | trunk: 42 | - MapboxCommon 43 | - MapboxCoreMaps 44 | - MapboxCoreNavigation 45 | - MapboxDirections 46 | - MapboxMaps 47 | - MapboxMobileEvents 48 | - MapboxNavigation 49 | - MapboxNavigationNative 50 | - MapboxSpeech 51 | - Polyline 52 | - Solar-dev 53 | - Turf 54 | 55 | EXTERNAL SOURCES: 56 | Flutter: 57 | :path: Flutter 58 | flutter_mapbox_navigation: 59 | :path: ".symlinks/plugins/flutter_mapbox_navigation/ios" 60 | 61 | SPEC CHECKSUMS: 62 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 63 | flutter_mapbox_navigation: 043dae117609883f693f08bdc283796eefb0de32 64 | MapboxCommon: c3a35f6884b80d898de9f11d88cb28c5caba584a 65 | MapboxCoreMaps: 03e7214fabb54d496ff56314ff8159dd264b6093 66 | MapboxCoreNavigation: 47937ebb39aab509987daa73d94e7cae144b9082 67 | MapboxDirections: a620d78a54312c392323ba211df8ae7dd9a28ab4 68 | MapboxMaps: 85610575a8871b3f5e98be2a234f0229a33324a7 69 | MapboxMobileEvents: de50b3a4de180dd129c326e09cd12c8adaaa46d6 70 | MapboxNavigation: 8c4a3f75a4a57a837471af2034d53d24be83f9a5 71 | MapboxNavigationNative: 56d91300b3d7a3697c700941b33c315a9a301716 72 | MapboxSpeech: cd25ef99c3a3d2e0da72620ff558276ea5991a77 73 | Polyline: 2a1f29f87f8d9b7de868940f4f76deb8c678a5b1 74 | Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 75 | Turf: 469ce2c3d22e5e8e4818d5a3b254699a5c89efa4 76 | 77 | PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048 78 | 79 | COCOAPODS: 1.12.1 80 | -------------------------------------------------------------------------------- /lib/src/models/route_progress_event.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: public_member_api_docs 2 | 3 | import 'package:flutter_mapbox_navigation/src/helpers.dart'; 4 | import 'package:flutter_mapbox_navigation/src/models/route_leg.dart'; 5 | 6 | ///This class contains all progress information at any given time 7 | ///during a navigation session. This progress includes information for the 8 | ///current route, leg and step the user is traversing along. With every new 9 | ///valid location update, a new route progress will be generated using 10 | ///the latest information. 11 | class RouteProgressEvent { 12 | RouteProgressEvent({ 13 | this.arrived, 14 | this.distance, 15 | this.duration, 16 | this.distanceTraveled, 17 | this.currentLegDistanceTraveled, 18 | this.currentLegDistanceRemaining, 19 | this.currentStepInstruction, 20 | this.currentLeg, 21 | this.priorLeg, 22 | this.remainingLegs, 23 | this.legIndex, 24 | this.stepIndex, 25 | this.isProgressEvent, 26 | }); 27 | 28 | RouteProgressEvent.fromJson(Map json) { 29 | isProgressEvent = json['arrived'] != null; 30 | arrived = json['arrived'] == null ? false : json['arrived'] as bool?; 31 | distance = isNullOrZero(json['distance'] as num?) 32 | ? 0.0 33 | : (json['distance'] as num).toDouble(); 34 | duration = isNullOrZero(json['duration'] as num?) 35 | ? 0.0 36 | : (json['duration'] as num).toDouble(); 37 | distanceTraveled = isNullOrZero(json['distanceTraveled'] as num?) 38 | ? 0.0 39 | : (json['distanceTraveled'] as num).toDouble(); 40 | currentLegDistanceTraveled = 41 | isNullOrZero(json['currentLegDistanceTraveled'] as num?) 42 | ? 0.0 43 | : (json['currentLegDistanceTraveled'] as num).toDouble(); 44 | currentLegDistanceRemaining = 45 | isNullOrZero(json['currentLegDistanceRemaining'] as num?) 46 | ? 0.0 47 | : (json['currentLegDistanceRemaining'] as num).toDouble(); 48 | currentStepInstruction = json['currentStepInstruction'] as String?; 49 | currentLeg = json['currentLeg'] == null 50 | ? null 51 | : RouteLeg.fromJson(json['currentLeg'] as Map); 52 | priorLeg = json['priorLeg'] == null 53 | ? null 54 | : RouteLeg.fromJson(json['priorLeg'] as Map); 55 | remainingLegs = (json['remainingLegs'] as List?) 56 | ?.map( 57 | (e) => 58 | e == null ? null : RouteLeg.fromJson(e as Map), 59 | ) 60 | .cast() 61 | .toList(); 62 | legIndex = json['legIndex'] as int?; 63 | stepIndex = json['stepIndex'] as int?; 64 | } 65 | 66 | bool? arrived; 67 | double? distance; 68 | double? duration; 69 | double? distanceTraveled; 70 | double? currentLegDistanceTraveled; 71 | double? currentLegDistanceRemaining; 72 | String? currentStepInstruction; 73 | RouteLeg? currentLeg; 74 | RouteLeg? priorLeg; 75 | List? remainingLegs; 76 | int? legIndex; 77 | int? stepIndex; 78 | bool? isProgressEvent; 79 | } 80 | -------------------------------------------------------------------------------- /linux/flutter_mapbox_navigation_plugin.cc: -------------------------------------------------------------------------------- 1 | #include "include/flutter_mapbox_navigation/flutter_mapbox_navigation_plugin.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #define FLUTTER_MAPBOX_NAVIGATION_PLUGIN(obj) \ 10 | (G_TYPE_CHECK_INSTANCE_CAST((obj), flutter_mapbox_navigation_plugin_get_type(), \ 11 | FlutterMapboxNavigationPlugin)) 12 | 13 | struct _FlutterMapboxNavigationPlugin { 14 | GObject parent_instance; 15 | }; 16 | 17 | G_DEFINE_TYPE(FlutterMapboxNavigationPlugin, flutter_mapbox_navigation_plugin, g_object_get_type()) 18 | 19 | // Called when a method call is received from Flutter. 20 | static void flutter_mapbox_navigation_plugin_handle_method_call( 21 | FlutterMapboxNavigationPlugin* self, 22 | FlMethodCall* method_call) { 23 | g_autoptr(FlMethodResponse) response = nullptr; 24 | 25 | const gchar* method = fl_method_call_get_name(method_call); 26 | 27 | if (strcmp(method, "getPlatformVersion") == 0) { 28 | struct utsname uname_data = {}; 29 | uname(&uname_data); 30 | g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version); 31 | g_autoptr(FlValue) result = fl_value_new_string(version); 32 | response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); 33 | } else { 34 | response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); 35 | } 36 | 37 | fl_method_call_respond(method_call, response, nullptr); 38 | } 39 | 40 | static void flutter_mapbox_navigation_plugin_dispose(GObject* object) { 41 | G_OBJECT_CLASS(flutter_mapbox_navigation_plugin_parent_class)->dispose(object); 42 | } 43 | 44 | static void flutter_mapbox_navigation_plugin_class_init(FlutterMapboxNavigationPluginClass* klass) { 45 | G_OBJECT_CLASS(klass)->dispose = flutter_mapbox_navigation_plugin_dispose; 46 | } 47 | 48 | static void flutter_mapbox_navigation_plugin_init(FlutterMapboxNavigationPlugin* self) {} 49 | 50 | static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, 51 | gpointer user_data) { 52 | FlutterMapboxNavigationPlugin* plugin = FLUTTER_MAPBOX_NAVIGATION_PLUGIN(user_data); 53 | flutter_mapbox_navigation_plugin_handle_method_call(plugin, method_call); 54 | } 55 | 56 | void flutter_mapbox_navigation_plugin_register_with_registrar(FlPluginRegistrar* registrar) { 57 | FlutterMapboxNavigationPlugin* plugin = FLUTTER_MAPBOX_NAVIGATION_PLUGIN( 58 | g_object_new(flutter_mapbox_navigation_plugin_get_type(), nullptr)); 59 | 60 | g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); 61 | g_autoptr(FlMethodChannel) channel = 62 | fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar), 63 | "flutter_mapbox_navigation", 64 | FL_METHOD_CODEC(codec)); 65 | fl_method_channel_set_method_call_handler(channel, method_call_cb, 66 | g_object_ref(plugin), 67 | g_object_unref); 68 | 69 | g_object_unref(plugin); 70 | } 71 | -------------------------------------------------------------------------------- /example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /lib/src/embedded/view.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/gestures.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter/rendering.dart'; 7 | import 'package:flutter/services.dart'; 8 | import 'package:flutter/widgets.dart'; 9 | import 'package:flutter_mapbox_navigation/src/embedded/controller.dart'; 10 | import 'package:flutter_mapbox_navigation/src/models/models.dart'; 11 | 12 | /// Callback method for when the navigation view is ready to be used. 13 | /// 14 | /// Pass to MapBoxNavigationView.onMapCreated to receive a 15 | /// [MapBoxNavigationViewController] when the 16 | /// map is created. 17 | typedef OnNavigationViewCreatedCallBack = void Function( 18 | MapBoxNavigationViewController controller, 19 | ); 20 | 21 | ///Embeddable Navigation View. 22 | class MapBoxNavigationView extends StatelessWidget { 23 | ///Embeddable Navigation View Constructor 24 | const MapBoxNavigationView({ 25 | super.key, 26 | this.options, 27 | this.onCreated, 28 | this.onRouteEvent, 29 | }); 30 | 31 | static const StandardMessageCodec _decoder = StandardMessageCodec(); 32 | 33 | /// MapBox options 34 | final MapBoxOptions? options; 35 | 36 | /// Callback when view is created 37 | final OnNavigationViewCreatedCallBack? onCreated; 38 | 39 | /// Value setter for RouteEvents 40 | final ValueSetter? onRouteEvent; 41 | 42 | /// View name 43 | static const String viewType = 'FlutterMapboxNavigationView'; 44 | 45 | @override 46 | Widget build(BuildContext context) { 47 | if (Platform.isAndroid) { 48 | // using Hybrid Composition 49 | return PlatformViewLink( 50 | viewType: viewType, 51 | surfaceFactory: (context, controller) { 52 | return AndroidViewSurface( 53 | controller: controller as AndroidViewController, 54 | gestureRecognizers: const >{}, 55 | hitTestBehavior: PlatformViewHitTestBehavior.opaque, 56 | ); 57 | }, 58 | onCreatePlatformView: (params) { 59 | return PlatformViewsService.initExpensiveAndroidView( 60 | id: params.id, 61 | viewType: viewType, 62 | layoutDirection: TextDirection.ltr, 63 | creationParams: options!.toMap(), 64 | creationParamsCodec: const StandardMessageCodec(), 65 | onFocus: () { 66 | params.onFocusChanged(true); 67 | }, 68 | ) 69 | ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) 70 | ..addOnPlatformViewCreatedListener(_onPlatformViewCreated) 71 | ..create(); 72 | }, 73 | ); 74 | } else if (Platform.isIOS) { 75 | return UiKitView( 76 | viewType: 'FlutterMapboxNavigationView', 77 | onPlatformViewCreated: _onPlatformViewCreated, 78 | creationParams: options!.toMap(), 79 | creationParamsCodec: _decoder, 80 | ); 81 | } else { 82 | return Container(); 83 | } 84 | } 85 | 86 | void _onPlatformViewCreated(int id) { 87 | if (onCreated == null) { 88 | return; 89 | } 90 | onCreated!(MapBoxNavigationViewController(id, onRouteEvent)); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/models/MapBoxRouteProgressEvent.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.models 2 | 3 | import com.google.gson.Gson 4 | import com.google.gson.JsonObject 5 | import com.mapbox.navigation.base.trip.model.RouteProgress 6 | 7 | class MapBoxRouteProgressEvent(progress: RouteProgress) { 8 | 9 | var arrived: Boolean? = null 10 | private var distance: Float? = null 11 | private var duration: Double? = null 12 | private var distanceTraveled: Float? = null 13 | private var currentLegDistanceTraveled: Float? = null 14 | private var currentLegDistanceRemaining: Float? = null 15 | private var currentStepInstruction: String? = null 16 | private var legIndex: Int? = null 17 | var stepIndex: Int? = null 18 | private var currentLeg: MapBoxRouteLeg? = null 19 | var priorLeg: MapBoxRouteLeg? = null 20 | lateinit var remainingLegs: List 21 | 22 | init { 23 | // val util = RouteUtils() 24 | // arrived = util.isArrivalEvent(progress) && util.isLastLeg(progress) 25 | distance = progress.distanceRemaining 26 | duration = progress.durationRemaining 27 | distanceTraveled = progress.distanceTraveled 28 | legIndex = progress.currentLegProgress?.legIndex 29 | // stepIndex = progress.stepIndex 30 | val leg = progress.currentLegProgress?.routeLeg 31 | if (leg != null) 32 | currentLeg = MapBoxRouteLeg(leg) 33 | currentStepInstruction = progress.bannerInstructions?.primary()?.text() 34 | currentLegDistanceTraveled = progress.currentLegProgress?.distanceTraveled 35 | currentLegDistanceRemaining = progress.currentLegProgress?.distanceRemaining 36 | } 37 | 38 | fun toJson(): String { 39 | return Gson().toJson(toJsonObject()) 40 | } 41 | 42 | private fun toJsonObject(): JsonObject { 43 | val json = JsonObject() 44 | addProperty(json, "distance", distance) 45 | addProperty(json, "duration", duration) 46 | addProperty(json, "distanceTraveled", distanceTraveled) 47 | addProperty(json, "legIndex", legIndex) 48 | addProperty(json, "currentLegDistanceRemaining", currentLegDistanceRemaining) 49 | addProperty(json, "currentLegDistanceTraveled", currentLegDistanceTraveled) 50 | addProperty(json, "currentStepInstruction", currentStepInstruction) 51 | 52 | if (currentLeg != null) { 53 | json.add("currentLeg", currentLeg!!.toJsonObject()) 54 | } 55 | 56 | return json 57 | } 58 | 59 | private fun addProperty(json: JsonObject, prop: String, value: Double?) { 60 | if (value != null) { 61 | json.addProperty(prop, value) 62 | } 63 | } 64 | 65 | private fun addProperty(json: JsonObject, prop: String, value: Int?) { 66 | if (value != null) { 67 | json.addProperty(prop, value) 68 | } 69 | } 70 | 71 | private fun addProperty(json: JsonObject, prop: String, value: String?) { 72 | if (value?.isNotEmpty() == true) { 73 | json.addProperty(prop, value) 74 | } 75 | } 76 | 77 | private fun addProperty(json: JsonObject, prop: String, value: Float?) { 78 | if (value != null) { 79 | json.addProperty(prop, value) 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/eopeter/fluttermapboxnavigation/models/views/EmbeddedNavigationMapView.kt: -------------------------------------------------------------------------------- 1 | package com.eopeter.fluttermapboxnavigation.models.views 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import android.view.View 6 | import com.eopeter.fluttermapboxnavigation.TurnByTurn 7 | import com.eopeter.fluttermapboxnavigation.databinding.NavigationActivityBinding 8 | import com.eopeter.fluttermapboxnavigation.models.MapBoxEvents 9 | import com.eopeter.fluttermapboxnavigation.utilities.PluginUtilities 10 | import com.mapbox.geojson.Point 11 | import com.mapbox.maps.MapView 12 | import com.mapbox.maps.plugin.gestures.OnMapClickListener 13 | import com.mapbox.maps.plugin.gestures.gestures 14 | import com.mapbox.navigation.dropin.map.MapViewObserver 15 | import io.flutter.plugin.common.BinaryMessenger 16 | import io.flutter.plugin.common.EventChannel 17 | import io.flutter.plugin.common.MethodChannel 18 | import io.flutter.plugin.platform.PlatformView 19 | import org.json.JSONObject 20 | 21 | class EmbeddedNavigationMapView( 22 | context: Context, 23 | activity: Activity, 24 | binding: NavigationActivityBinding, 25 | binaryMessenger: BinaryMessenger, 26 | vId: Int, 27 | args: Any?, 28 | accessToken: String 29 | ) : PlatformView, TurnByTurn(context, activity, binding, accessToken) { 30 | private val viewId: Int = vId 31 | private val messenger: BinaryMessenger = binaryMessenger 32 | private val arguments = args as Map<*, *> 33 | 34 | override fun initFlutterChannelHandlers() { 35 | methodChannel = MethodChannel(messenger, "flutter_mapbox_navigation/${viewId}") 36 | eventChannel = EventChannel(messenger, "flutter_mapbox_navigation/${viewId}/events") 37 | super.initFlutterChannelHandlers() 38 | } 39 | 40 | open fun initialize() { 41 | initFlutterChannelHandlers() 42 | initNavigation() 43 | 44 | if(!(this.arguments?.get("longPressDestinationEnabled") as Boolean)) { 45 | this.binding.navigationView.customizeViewOptions { 46 | enableMapLongClickIntercept = false; 47 | } 48 | } 49 | 50 | if((this.arguments?.get("enableOnMapTapCallback") as Boolean)) { 51 | this.binding.navigationView.registerMapObserver(onMapClick) 52 | } 53 | } 54 | 55 | override fun getView(): View { 56 | return binding.root 57 | } 58 | 59 | override fun dispose() { 60 | if((this.arguments?.get("enableOnMapTapCallback") as Boolean)) { 61 | this.binding.navigationView.unregisterMapObserver(onMapClick) 62 | } 63 | unregisterObservers() 64 | } 65 | 66 | /** 67 | * Notifies with attach and detach events on [MapView] 68 | */ 69 | private val onMapClick = object : MapViewObserver(), OnMapClickListener { 70 | 71 | override fun onAttached(mapView: MapView) { 72 | mapView.gestures.addOnMapClickListener(this) 73 | } 74 | 75 | override fun onDetached(mapView: MapView) { 76 | mapView.gestures.removeOnMapClickListener(this) 77 | } 78 | 79 | override fun onMapClick(point: Point): Boolean { 80 | var waypoint = mapOf( 81 | Pair("latitude", point.latitude().toString()), 82 | Pair("longitude", point.longitude().toString()) 83 | ) 84 | PluginUtilities.sendEvent(MapBoxEvents.ON_MAP_TAP, JSONObject(waypoint).toString()) 85 | return false 86 | } 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_mapbox_navigation_example 2 | description: Demonstrates how to use the flutter_mapbox_navigation plugin. 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 6 | 7 | environment: 8 | sdk: '>=2.19.4 <4.0.0' 9 | 10 | # Dependencies specify other packages that your package needs in order to work. 11 | # To automatically upgrade your package dependencies to the latest versions 12 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 13 | # dependencies can be manually updated by changing the version numbers below to 14 | # the latest version available on pub.dev. To see which dependencies have newer 15 | # versions available, run `flutter pub outdated`. 16 | dependencies: 17 | flutter: 18 | sdk: flutter 19 | 20 | flutter_mapbox_navigation: 21 | # When depending on this package from a real application you should use: 22 | # flutter_mapbox_navigation: ^x.y.z 23 | # See https://dart.dev/tools/pub/dependencies#version-constraints 24 | # The example app is bundled with the plugin so we use a path dependency on 25 | # the parent directory to use the current plugin's version. 26 | path: ../ 27 | 28 | # The following adds the Cupertino Icons font to your application. 29 | # Use with the CupertinoIcons class for iOS style icons. 30 | cupertino_icons: ^1.0.2 31 | 32 | dev_dependencies: 33 | flutter_test: 34 | sdk: flutter 35 | 36 | # The "flutter_lints" package below contains a set of recommended lints to 37 | # encourage good coding practices. The lint set provided by the package is 38 | # activated in the `analysis_options.yaml` file located at the root of your 39 | # package. See that file for information about deactivating specific lint 40 | # rules and activating additional ones. 41 | flutter_lints: ^2.0.0 42 | 43 | # For information on the generic Dart part of this file, see the 44 | # following page: https://dart.dev/tools/pub/pubspec 45 | 46 | # The following section is specific to Flutter packages. 47 | flutter: 48 | 49 | # The following line ensures that the Material Icons font is 50 | # included with your application, so that you can use the icons in 51 | # the material Icons class. 52 | uses-material-design: true 53 | 54 | # To add assets to your application, add an assets section, like this: 55 | # assets: 56 | # - images/a_dot_burr.jpeg 57 | # - images/a_dot_ham.jpeg 58 | 59 | # An image asset can refer to one or more resolution-specific "variants", see 60 | # https://flutter.dev/assets-and-images/#resolution-aware 61 | 62 | # For details regarding adding assets from package dependencies, see 63 | # https://flutter.dev/assets-and-images/#from-packages 64 | 65 | # To add custom fonts to your application, add a fonts section here, 66 | # in this "flutter" section. Each entry in this list should have a 67 | # "family" key with the font family name, and a "fonts" key with a 68 | # list giving the asset and other descriptors for the font. For 69 | # example: 70 | # fonts: 71 | # - family: Schyler 72 | # fonts: 73 | # - asset: fonts/Schyler-Regular.ttf 74 | # - asset: fonts/Schyler-Italic.ttf 75 | # style: italic 76 | # - family: Trajan Pro 77 | # fonts: 78 | # - asset: fonts/TrajanPro.ttf 79 | # - asset: fonts/TrajanPro_Bold.ttf 80 | # weight: 700 81 | # 82 | # For details regarding fonts from package dependencies, 83 | # see https://flutter.dev/custom-fonts/#from-packages 84 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /android/src/main/res/layout/components_navigation_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 26 | 27 | 31 | 32 | 39 | 40 | 41 | 50 | 51 | 60 | 61 | 70 | 71 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.eopeter" "\0" 93 | VALUE "FileDescription", "flutter_mapbox_navigation_example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "flutter_mapbox_navigation_example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.eopeter. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "flutter_mapbox_navigation_example.exe" "\0" 98 | VALUE "ProductName", "flutter_mapbox_navigation_example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responsponds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /example/linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "flutter_mapbox_navigation_example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "flutter_mapbox_navigation_example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.eopeter.fluttermapboxnavigation' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.7.10' 6 | ext.android_gradle_version = '7.4.2' 7 | repositories { 8 | google() 9 | mavenCentral() 10 | maven { 11 | url 'https://api.mapbox.com/downloads/v2/releases/maven' 12 | authentication { 13 | basic(BasicAuthentication) 14 | } 15 | credentials { 16 | username = "mapbox" 17 | password = project.hasProperty('MAPBOX_DOWNLOADS_TOKEN') ? project.property('MAPBOX_DOWNLOADS_TOKEN') : System.getenv('MAPBOX_DOWNLOADS_TOKEN') 18 | if (password == null || password == "") { 19 | throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.") 20 | } 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | classpath "com.android.tools.build:gradle:$android_gradle_version" 27 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 28 | classpath "com.mapbox.gradle.plugins:access-token:0.4.0" 29 | } 30 | } 31 | 32 | rootProject.allprojects { 33 | repositories { 34 | google() 35 | mavenCentral() 36 | maven { url 'https://plugins.gradle.org/m2' } 37 | maven { 38 | url 'https://api.mapbox.com/downloads/v2/releases/maven' 39 | authentication { 40 | basic(BasicAuthentication) 41 | } 42 | credentials { 43 | username = "mapbox" 44 | password = project.hasProperty('MAPBOX_DOWNLOADS_TOKEN') ? project.property('MAPBOX_DOWNLOADS_TOKEN') : System.getenv('MAPBOX_DOWNLOADS_TOKEN') 45 | if (password == null || password == "") { 46 | throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.") 47 | } 48 | } 49 | } 50 | } 51 | } 52 | 53 | apply plugin: 'com.android.library' 54 | apply plugin: 'kotlin-android' 55 | 56 | android { 57 | namespace 'com.eopeter.fluttermapboxnavigation' 58 | compileSdkVersion 33 59 | 60 | sourceSets { 61 | main.java.srcDirs += 'src/main/kotlin' 62 | } 63 | defaultConfig { 64 | minSdkVersion 21 65 | targetSdkVersion 33 66 | multiDexEnabled true 67 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 68 | } 69 | 70 | lintOptions { 71 | disable 'InvalidPackage' 72 | abortOnError false 73 | } 74 | 75 | compileOptions { 76 | sourceCompatibility JavaVersion.VERSION_1_8 77 | targetCompatibility JavaVersion.VERSION_1_8 78 | } 79 | 80 | kotlinOptions { 81 | jvmTarget = '1.8' 82 | } 83 | 84 | buildFeatures{ 85 | viewBinding = true 86 | } 87 | } 88 | 89 | dependencies { 90 | // Mapbox Navigation SDK 91 | implementation "com.mapbox.navigation:copilot:2.16.0" 92 | implementation "com.mapbox.navigation:ui-app:2.16.0" 93 | implementation "com.mapbox.navigation:ui-dropin:2.16.0" 94 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 95 | implementation 'com.jakewharton.timber:timber:4.7.1' 96 | implementation 'com.google.code.gson:gson:2.8.9' 97 | 98 | implementation "androidx.core:core-ktx:1.9.0" 99 | implementation "com.google.android.material:material:1.8.0" 100 | implementation "androidx.appcompat:appcompat:1.6.1" 101 | implementation "androidx.cardview:cardview:1.0.0" 102 | implementation "androidx.constraintlayout:constraintlayout:2.1.4" 103 | implementation "com.google.android.gms:play-services-location:21.0.1" 104 | debugImplementation "com.squareup.leakcanary:leakcanary-android:2.9.1" 105 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" 106 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" 107 | implementation 'androidx.annotation:annotation:1.6.0' 108 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' 109 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 110 | } 111 | -------------------------------------------------------------------------------- /lib/src/flutter_mapbox_navigation_platform_interface.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:flutter_mapbox_navigation/src/flutter_mapbox_navigation_method_channel.dart'; 3 | import 'package:flutter_mapbox_navigation/src/models/models.dart'; 4 | import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 5 | 6 | /// FlutterMapboxNavigationPlatform abstract class 7 | abstract class FlutterMapboxNavigationPlatform extends PlatformInterface { 8 | /// Constructs a FlutterMapboxNavigationPlatform. 9 | FlutterMapboxNavigationPlatform() : super(token: _token); 10 | 11 | static final Object _token = Object(); 12 | 13 | static FlutterMapboxNavigationPlatform _instance = 14 | MethodChannelFlutterMapboxNavigation(); 15 | 16 | /// The default instance of [FlutterMapboxNavigationPlatform] to use. 17 | /// 18 | /// Defaults to [MethodChannelFlutterMapboxNavigation]. 19 | static FlutterMapboxNavigationPlatform get instance => _instance; 20 | 21 | /// Platform-specific implementations should set this with their own 22 | /// platform-specific class that extends [FlutterMapboxNavigationPlatform] 23 | /// when they register themselves. 24 | static set instance(FlutterMapboxNavigationPlatform instance) { 25 | PlatformInterface.verifyToken(instance, _token); 26 | _instance = instance; 27 | } 28 | 29 | ///Current Device OS Version 30 | Future getPlatformVersion() { 31 | throw UnimplementedError('platformVersion() has not been implemented.'); 32 | } 33 | 34 | ///Total distance remaining in meters along route. 35 | Future getDistanceRemaining() { 36 | throw UnimplementedError( 37 | 'getDistanceRemaining() has not been implemented.', 38 | ); 39 | } 40 | 41 | ///Total seconds remaining on all legs. 42 | Future getDurationRemaining() { 43 | throw UnimplementedError( 44 | 'getDurationRemaining() has not been implemented.', 45 | ); 46 | } 47 | 48 | /// Free-drive mode is a unique Mapbox Navigation SDK feature that allows 49 | /// drivers to navigate without a set destination. This mode is sometimes 50 | /// referred to as passive navigation. 51 | /// [options] options used to generate the route and used while navigating 52 | /// Begins to generate Route Progress 53 | /// 54 | Future startFreeDrive(MapBoxOptions options) async { 55 | throw UnimplementedError('startFreeDrive() has not been implemented.'); 56 | } 57 | 58 | ///Show the Navigation View and Begins Direction Routing 59 | /// 60 | /// [wayPoints] must not be null and have at least 2 items. A collection of 61 | /// [WayPoint](longitude, latitude and name). Must be at least 2 or at 62 | /// most 25. Cannot use drivingWithTraffic mode if more than 3-waypoints. 63 | /// [options] options used to generate the route and used while navigating 64 | /// Begins to generate Route Progress 65 | /// 66 | Future startNavigation( 67 | List wayPoints, 68 | MapBoxOptions options, 69 | ) async { 70 | throw UnimplementedError('startNavigation() has not been implemented.'); 71 | } 72 | 73 | ///Adds waypoints or stops to an on-going navigation 74 | /// 75 | /// [wayPoints] must not be null and have at least 1 item. The way points will 76 | /// be inserted after the currently navigating \ 77 | /// waypoint in the existing navigation 78 | Future addWayPoints({required List wayPoints}) { 79 | throw UnimplementedError( 80 | 'addWayPoints({required wayPoints }) has not been implemented.', 81 | ); 82 | } 83 | 84 | ///Ends Navigation and Closes the Navigation View 85 | Future finishNavigation() async { 86 | throw UnimplementedError('finishNavigation() has not been implemented.'); 87 | } 88 | 89 | /// Will download the navigation engine and the user's region 90 | /// to allow offline routing 91 | Future enableOfflineRouting() async { 92 | throw UnimplementedError( 93 | 'enableOfflineRouting() has not been implemented.', 94 | ); 95 | } 96 | 97 | /// Event listener 98 | Future registerRouteEventListener( 99 | ValueSetter listener, 100 | ) async { 101 | throw UnimplementedError( 102 | 'registerEventListener() has not been implemented.', 103 | ); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /lib/src/flutter_mapbox_navigation.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: use_setters_to_change_properties 2 | 3 | import 'dart:async'; 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter/widgets.dart'; 7 | import 'package:flutter_mapbox_navigation/src/flutter_mapbox_navigation_platform_interface.dart'; 8 | import 'package:flutter_mapbox_navigation/src/models/models.dart'; 9 | 10 | /// Turn-By-Turn Navigation Provider 11 | class MapBoxNavigation { 12 | static final MapBoxNavigation _instance = MapBoxNavigation(); 13 | 14 | /// get current instance of this class 15 | static MapBoxNavigation get instance => _instance; 16 | 17 | MapBoxOptions _defaultOptions = MapBoxOptions( 18 | zoom: 15, 19 | tilt: 0, 20 | bearing: 0, 21 | enableRefresh: false, 22 | alternatives: true, 23 | voiceInstructionsEnabled: true, 24 | bannerInstructionsEnabled: true, 25 | allowsUTurnAtWayPoints: true, 26 | mode: MapBoxNavigationMode.drivingWithTraffic, 27 | units: VoiceUnits.imperial, 28 | simulateRoute: false, 29 | animateBuildRoute: true, 30 | longPressDestinationEnabled: true, 31 | language: 'en', 32 | ); 33 | 34 | /// setter to set default options 35 | void setDefaultOptions(MapBoxOptions options) { 36 | _defaultOptions = options; 37 | } 38 | 39 | /// Getter to retriev default options 40 | MapBoxOptions getDefaultOptions() { 41 | return _defaultOptions; 42 | } 43 | 44 | ///Current Device OS Version 45 | Future getPlatformVersion() { 46 | return FlutterMapboxNavigationPlatform.instance.getPlatformVersion(); 47 | } 48 | 49 | ///Total distance remaining in meters along route. 50 | Future getDistanceRemaining() { 51 | return FlutterMapboxNavigationPlatform.instance.getDistanceRemaining(); 52 | } 53 | 54 | ///Total seconds remaining on all legs. 55 | Future getDurationRemaining() { 56 | return FlutterMapboxNavigationPlatform.instance.getDurationRemaining(); 57 | } 58 | 59 | ///Adds waypoints or stops to an on-going navigation 60 | /// 61 | /// [wayPoints] must not be null and have at least 1 item. The way points will 62 | /// be inserted after the currently navigating waypoint 63 | /// in the existing navigation 64 | Future addWayPoints({required List wayPoints}) async { 65 | return FlutterMapboxNavigationPlatform.instance 66 | .addWayPoints(wayPoints: wayPoints); 67 | } 68 | 69 | /// Free-drive mode is a unique Mapbox Navigation SDK feature that allows 70 | /// drivers to navigate without a set destination. 71 | /// This mode is sometimes referred to as passive navigation. 72 | /// Begins to generate Route Progress 73 | /// 74 | Future startFreeDrive({MapBoxOptions? options}) async { 75 | options ??= _defaultOptions; 76 | return FlutterMapboxNavigationPlatform.instance.startFreeDrive(options); 77 | } 78 | 79 | ///Show the Navigation View and Begins Direction Routing 80 | /// 81 | /// [wayPoints] must not be null and have at least 2 items. A collection of 82 | /// [WayPoint](longitude, latitude and name). Must be at least 2 or 83 | /// at most 25. Cannot use drivingWithTraffic mode if more than 3-waypoints. 84 | /// [options] options used to generate the route and used while navigating 85 | /// Begins to generate Route Progress 86 | /// 87 | Future startNavigation({ 88 | required List wayPoints, 89 | MapBoxOptions? options, 90 | }) async { 91 | options ??= _defaultOptions; 92 | return FlutterMapboxNavigationPlatform.instance 93 | .startNavigation(wayPoints, options); 94 | } 95 | 96 | ///Ends Navigation and Closes the Navigation View 97 | Future finishNavigation() async { 98 | return FlutterMapboxNavigationPlatform.instance.finishNavigation(); 99 | } 100 | 101 | /// Will download the navigation engine and the user's region 102 | /// to allow offline routing 103 | Future enableOfflineRouting() async { 104 | return FlutterMapboxNavigationPlatform.instance.enableOfflineRouting(); 105 | } 106 | 107 | /// Event listener for RouteEvents 108 | Future registerRouteEventListener( 109 | ValueSetter listener, 110 | ) async { 111 | return FlutterMapboxNavigationPlatform.instance 112 | .registerRouteEventListener(listener); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(flutter_mapbox_navigation_example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "flutter_mapbox_navigation_example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.2 2 | * Fix issue with voice units in Android 3 | * Fix BannerText, VoiceInstruction and Off Route Events 4 | 5 | ## 0.2.1 6 | * Fix issue with setting the language in Android 7 | 8 | ## 0.2.0 9 | * Update MapBox Android Version 10 | * Resolve issue where Navigation Does Not Dismiss Activity on Cancel 11 | 12 | ## 0.1.9 13 | * Android Day/Night Style Default Values [PR 272](https://github.com/eopeter/flutter_mapbox_navigation/pull/272) 14 | * Fix iOS Embedded Clear Route Issue [PR 284](https://github.com/eopeter/flutter_mapbox_navigation/pull/284) 15 | * Fix Route Events Not Sent [PR 288](https://github.com/eopeter/flutter_mapbox_navigation/pull/288) 16 | * Set WayPoint IsSilent to default false 17 | 18 | ## 0.1.8 19 | * Fix Android NavigationMode [261](https://github.com/eopeter/flutter_mapbox_navigation/pull/261) 20 | 21 | ## 0.1.7 22 | * Fix Android mainClass entry Error 23 | 24 | ## 0.1.6 25 | * Embedded Clear Route Bug Fix 26 | 27 | ## 0.1.5 28 | * Bug Fixes [248](https://github.com/eopeter/flutter_mapbox_navigation/pull/248) and [250](https://github.com/eopeter/flutter_mapbox_navigation/pull/250) 29 | 30 | ## 0.1.4 31 | * Android Send Cancel Event [235](https://github.com/eopeter/flutter_mapbox_navigation/pull/235) 32 | * iOS Receive Feedback Sent to Mapbox on Dart Side; Ability to Turn On/Off Show Feedback [235](https://github.com/eopeter/flutter_mapbox_navigation/pull/235) 33 | * Add Free Drive Mode [240](https://github.com/eopeter/flutter_mapbox_navigation/pull/240) 34 | 35 | ## 0.1.3 36 | * Android Send Cancel Event [236](https://github.com/eopeter/flutter_mapbox_navigation/pull/236) 37 | 38 | ## 0.1.2 39 | * Android embedded view now working [#225](https://github.com/eopeter/flutter_mapbox_navigation/pull/225) 40 | * Fixes Progress Changed and Route Build Event Data serialization on Android [#227](https://github.com/eopeter/flutter_mapbox_navigation/pull/227) 41 | 42 | ## 0.1.1 43 | * Android: move LeakCanary as DebugImplementation [#221](https://github.com/eopeter/flutter_mapbox_navigation/pull/221) 44 | * Emit Route Data Upon Route Build [#218](https://github.com/eopeter/flutter_mapbox_navigation/pull/218) 45 | * Implement Silent Waypoints [#214](https://github.com/eopeter/flutter_mapbox_navigation/pull/214) 46 | 47 | ## 0.1.0 48 | * breaking changes 49 | * Android Gradle Upgrade 50 | * Bug Fixes 51 | * MapBox Library Upgrade 52 | * iOS MapBox Token Property Name in info.plist is now MBXAccessToken 53 | * Embedded Nav Broken in Android - Working On It 54 | 55 | ## 0.0.26 56 | * not implemented bug for onNextLegStart 57 | 58 | ## 0.0.25 59 | * bug fixes 60 | 61 | ## 0.0.24 62 | * bug fixes 63 | 64 | ## 0.0.22 65 | * bug fixes 66 | 67 | ## 0.0.21 68 | * Fix static analysis bug 69 | 70 | ## 0.0.20 71 | * Upgrade Mapbox Libraries 72 | * Upgrade to Null Safety 73 | 74 | ## 0.0.19 75 | * Upgrade MapBox Android to v1.0.1 76 | * Gradle Updates 77 | * Bug Fixes 78 | 79 | ## 0.0.18 80 | * Bug Fixes 81 | 82 | ## 0.0.17 83 | * Offline Navigation 84 | * Bug Fixes 85 | 86 | ## 0.0.16 87 | * Refactoring with breaking changes. Sorry :-( 88 | * Add Embedded Navigation 89 | * Consolidated Navigation Options 90 | * Add ability to change map style 91 | * Can select alternate routes 92 | 93 | ## 0.0.15 94 | * Remove Dialog at WayPoint Arrival 95 | * Tweak iOS WayPoint navigation behavior to match Android 96 | * Bug Fixes 97 | 98 | ## 0.0.14 99 | * Bug Fixes 100 | 101 | ## 0.0.13 102 | * Apply Dart Formats 103 | * Added Some Documentation 104 | * Bug Fixes 105 | 106 | ## 0.0.12 107 | * Added Multi-Stop WayPoint Navigation 108 | * More Detailed Progress Events like route leg and step details 109 | * MapBox Version Updates 110 | 111 | ## 0.0.11 112 | * Deprecated NavigationMode. Use MapBoxNavigationMode instead. 113 | * Upgrade MapBox Libraries 114 | * Android Gradle Update 115 | * Bug Fixes 116 | 117 | ## 0.0.10 118 | * Added ability to override the measurement system used in spoken instructions 119 | 120 | ## 0.0.9 121 | * Added option to change default language. See example in Read Me. This is only the language for the spoken instruction. 122 | 123 | ## 0.0.8 124 | * Plugin upgrade for Flutter 1.12 125 | 126 | ## 0.0.7 127 | * Remove extraneous jars for Kotlin-Reflect Inserted to lib folder by Android Studio 128 | 129 | ## 0.0.6 130 | * Android Bug Fix 131 | 132 | ## 0.0.5 133 | *[Breaking] Constructor and Name Change. See Example 134 | * Route Progress And Arrival Events on iOS. Android Pending. 135 | * Ending Navigation 136 | * Navigation Modes Support (driving, walking, cycling) 137 | * Simulation Mode Support 138 | 139 | ## 0.0.4 140 | * Gradle 5.4.1 Support 141 | * Mapbox Update to Current Versions 142 | * iOS 10 Minimum Requirement 143 | 144 | ## 0.0.3 145 | 146 | * Added AndroidX Support 147 | 148 | ## 0.0.2 149 | 150 | * Added Android Support 151 | 152 | ## 0.0.1 153 | 154 | * Initial Release That Targets only iOS 155 | --------------------------------------------------------------------------------