├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── feature_request.yml │ └── support_request.md ├── PULL_REQUEST_TEMPLATE.md ├── blunderbuss.yml ├── dependabot.yml └── workflows │ ├── analyze.yaml │ ├── licence-check.yaml │ ├── publish.yml │ ├── release-please.yml │ ├── scripts │ └── validate-formatting.sh │ └── test-and-build.yaml ├── .gitignore ├── .metadata ├── .release-please-manifest.json ├── ANDROIDAUTO.md ├── CARPLAY.MD ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── build.gradle ├── proguard.txt ├── settings.gradle └── src │ ├── main │ ├── AndroidManifest.xml │ └── kotlin │ │ └── com │ │ └── google │ │ └── maps │ │ └── flutter │ │ └── navigation │ │ ├── AndroidAutoBaseScreen.kt │ │ ├── CircleBuilder.kt │ │ ├── CircleController.kt │ │ ├── CircleOptionsSink.kt │ │ ├── Convert.kt │ │ ├── GoogleMapView.kt │ │ ├── GoogleMapsAutoMapView.kt │ │ ├── GoogleMapsAutoViewMessageHandler.kt │ │ ├── GoogleMapsBaseMapView.kt │ │ ├── GoogleMapsImageRegistryMessageHandler.kt │ │ ├── GoogleMapsNavigationInspectorHandler.kt │ │ ├── GoogleMapsNavigationNavUpdatesService.kt │ │ ├── GoogleMapsNavigationPlugin.kt │ │ ├── GoogleMapsNavigationSessionManager.kt │ │ ├── GoogleMapsNavigationSessionMessageHandler.kt │ │ ├── GoogleMapsNavigationView.kt │ │ ├── GoogleMapsViewFactory.kt │ │ ├── GoogleMapsViewMessageHandler.kt │ │ ├── GoogleMapsViewRegistry.kt │ │ ├── ImageRegistry.kt │ │ ├── MapOptions.kt │ │ ├── MarkerBuilder.kt │ │ ├── MarkerController.kt │ │ ├── MarkerOptionsSink.kt │ │ ├── NavigationViewConfiguration.kt │ │ ├── PolygonBuilder.kt │ │ ├── PolygonController.kt │ │ ├── PolygonOptionsSink.kt │ │ ├── PolylineBuilder.kt │ │ ├── PolylineController.kt │ │ ├── PolylineOptionsSink.kt │ │ ├── QueuedBitmap.kt │ │ ├── RegisteredImage.kt │ │ └── messages.g.kt │ └── test │ └── kotlin │ └── com │ └── google │ └── maps │ └── flutter │ └── navigation │ ├── CircleBuilderTest.kt │ ├── CircleControllerTest.kt │ ├── ConvertTest.kt │ ├── MarkerBuilderTest.kt │ ├── MarkerControllerTest.kt │ ├── PolygonBuilderTest.kt │ ├── PolygonControllerTest.kt │ ├── PolylineBuilderTest.kt │ └── PolylineControllerTest.kt ├── dartdoc_options.yaml ├── doc ├── image-registry.md ├── map-view.md ├── navigation-view.md └── navigation.md ├── example ├── .gitignore ├── README.md ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── google │ │ │ │ └── maps │ │ │ │ └── flutter │ │ │ │ └── navigation_example │ │ │ │ └── MainActivityTest.java │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── google │ │ │ │ │ └── maps │ │ │ │ │ └── flutter │ │ │ │ │ └── navigation_example │ │ │ │ │ ├── MainActivity.kt │ │ │ │ │ ├── ManeuverConverter.kt │ │ │ │ │ ├── SampleAndroidAutoScreen.kt │ │ │ │ │ ├── SampleAndroidAutoService.kt │ │ │ │ │ └── SampleAndroidAutoSession.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── 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 │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ ├── values │ │ │ │ └── styles.xml │ │ │ │ └── xml │ │ │ │ └── automotive_app_desc.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── assets │ ├── 2.0x │ │ └── marker1.png │ ├── marker1.png │ ├── night_style.json │ └── sepia_style.json ├── integration_test │ ├── shared.dart │ ├── t01_initialization_test.dart │ ├── t02_session_test.dart │ ├── t03_navigation_test.dart │ ├── t04_navigation_ui_test.dart │ ├── t05_camera_test.dart │ ├── t06_map_test.dart │ ├── t07_event_listener_test.dart │ └── t08_marker_polygon_polyline_circle_test.dart ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── Runner.xcscheme │ │ │ └── RunnerCarPlay.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── AppDelegateCarPlay.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── 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-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── CarSceneDelegate.swift │ │ ├── Info-CarPlay.plist │ │ ├── Info.plist │ │ ├── PhoneSceneDelegate.swift │ │ ├── Runner-Bridging-Header.h │ │ ├── RunnerCarPlay.entitlements │ │ └── main.swift │ ├── RunnerTests │ │ └── ConvertTests.swift │ └── RunnerUITests │ │ └── RunnerUITests.m ├── lib │ ├── main.dart │ ├── pages │ │ ├── camera.dart │ │ ├── circles.dart │ │ ├── map.dart │ │ ├── markers.dart │ │ ├── multiple_views.dart │ │ ├── navigation.dart │ │ ├── navigation_without_map.dart │ │ ├── pages.dart │ │ ├── polygons.dart │ │ ├── polylines.dart │ │ ├── turn_by_turn.dart │ │ └── widget_initialization.dart │ ├── routes_api │ │ └── routes_api.dart │ ├── utils │ │ ├── constants.dart │ │ ├── location_permissions.dart │ │ ├── maneuver_map.dart │ │ ├── overlay_options.dart │ │ ├── remaining_distance.dart │ │ ├── remaining_time.dart │ │ ├── snackbar.dart │ │ ├── terms_of_service.dart │ │ ├── utils.dart │ │ └── waypoint_marker.dart │ └── widgets │ │ ├── camera_position_editor.dart │ │ ├── dropdown_button.dart │ │ ├── latlng_bound_editor.dart │ │ ├── latlng_editor.dart │ │ ├── page.dart │ │ ├── slider_editor.dart │ │ ├── switch.dart │ │ └── widgets.dart └── pubspec.yaml ├── header_template.txt ├── ios ├── .gitignore ├── google_navigation_flutter.podspec └── google_navigation_flutter │ ├── Package.swift │ └── Sources │ └── google_navigation_flutter │ ├── BaseCarSceneDelegate.swift │ ├── Convert+MapConfiguration.swift │ ├── Convert.swift │ ├── GMSCircle+Util.swift │ ├── GMSPath+Util.swift │ ├── GMSPolygon+Util.swift │ ├── GMSPolyline+Util.swift │ ├── GoogleMapsAutoViewMessageHandler.swift │ ├── GoogleMapsImageRegistryMessageHandler.swift │ ├── GoogleMapsNavigationInspectorHandler.swift │ ├── GoogleMapsNavigationPlugin.swift │ ├── GoogleMapsNavigationSessionManager.swift │ ├── GoogleMapsNavigationSessionMessageHandler.swift │ ├── GoogleMapsNavigationView.swift │ ├── GoogleMapsNavigationViewFactory.swift │ ├── GoogleMapsNavigationViewMessageHandler.swift │ ├── GoogleMapsNavigationViewRegistry.swift │ ├── ImageRegistry.swift │ ├── ImageResizer.swift │ ├── LocationManager.swift │ ├── MapConfiguration.swift │ ├── MarkerController.swift │ ├── PrivacyInfo.xcprivacy │ ├── RegisteredImage.swift │ ├── Utilities.swift │ ├── ViewSettledDelegate.swift │ ├── ViewStateAwareGMSMapView.swift │ └── messages.g.swift ├── lib ├── google_navigation_flutter.dart └── src │ ├── google_maps_auto_view_controller.dart │ ├── google_maps_image_registry.dart │ ├── google_maps_map_view.dart │ ├── google_maps_map_view_controller.dart │ ├── google_maps_navigation_view.dart │ ├── google_maps_navigation_view_controller.dart │ ├── google_navigation_flutter.dart │ ├── google_navigation_flutter_android.dart │ ├── google_navigation_flutter_ios.dart │ ├── google_navigation_flutter_platform_interface.dart │ ├── inspector │ ├── inspector_android.dart │ ├── inspector_ios.dart │ └── inspector_platform.dart │ ├── method_channel │ ├── auto_view_api.dart │ ├── convert │ │ ├── camera.dart │ │ ├── circle.dart │ │ ├── convert.dart │ │ ├── destinations.dart │ │ ├── latlng.dart │ │ ├── latlng_bounds.dart │ │ ├── map_type.dart │ │ ├── marker.dart │ │ ├── navigation.dart │ │ ├── navigation_display_options.dart │ │ ├── navigation_route_token_options.dart │ │ ├── navigation_routing_options.dart │ │ ├── navigation_waypoint.dart │ │ ├── navinfo.dart │ │ ├── pattern.dart │ │ ├── polygon.dart │ │ ├── polyline.dart │ │ └── simulation.dart │ ├── image_api.dart │ ├── map_view_api.dart │ ├── messages.g.dart │ ├── method_channel.dart │ └── session_api.dart │ ├── navigator │ ├── google_navigation_flutter_navigator.dart │ └── google_navigation_flutter_simulator.dart │ ├── types │ ├── circles.dart │ ├── images.dart │ ├── lat_lng.dart │ ├── lat_lng_bounds.dart │ ├── markers.dart │ ├── navigation_destinations.dart │ ├── navigation_initialization_params.dart │ ├── navigation_view_types.dart │ ├── navinfo.dart │ ├── polygons.dart │ ├── polylines.dart │ ├── simulation.dart │ ├── stroke_patterns.dart │ ├── types.dart │ └── view_initialization_options.dart │ └── utils │ └── color.dart ├── melos.yaml ├── pigeons ├── copyright.txt └── messages.dart ├── pubspec.yaml ├── release-please-config.json ├── test ├── google_navigation_flutter_test.dart ├── google_navigation_flutter_test.mocks.dart ├── messages_test.g.dart ├── navigation_polygons_test.dart └── navigation_types_test.dart └── tool └── test-ios.sh /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest a feature or improvement for this package 3 | title: '[Feature request]: ' 4 | labels: 'type: feature request, triage me' 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for suggesting an improvement for googlemaps/flutter-navigation-sdk! 10 | 11 | If you have a support contract with Google, please create an issue in the [support console](https://console.cloud.google.com/google/maps-apis/support/createcase). This will ensure a timely response. 12 | - type: checkboxes 13 | attributes: 14 | label: Is there an existing issue for this? 15 | description: Please ensure your feature request is not already covered in [existing issues](https://github.com/googlemaps/flutter-navigation-sdk/issues). 16 | options: 17 | - label: I have searched the existing issues 18 | required: true 19 | - type: textarea 20 | attributes: 21 | label: Use case 22 | description: | 23 | Please tell us the problem you are running into that led to you wanting 24 | a new feature. 25 | 26 | Is your feature request related to a problem? Please give a clear and 27 | concise description of what the problem is. 28 | 29 | Describe the alternative solutions you've considered. Is there a package 30 | existing that already solves this? 31 | validations: 32 | required: true 33 | - type: textarea 34 | attributes: 35 | label: Proposal 36 | description: | 37 | Briefly but precisely describe what you would like the package to be able to do. 38 | 39 | Consider attaching something showing what you are imagining: 40 | * images 41 | * videos 42 | * code samples 43 | validations: 44 | required: true 45 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support request 3 | about: 4 | If you have a support contract with Google, please create an issue in the Google 5 | Cloud Support console. 6 | title: '[Support Request]: ' 7 | labels: 'triage me, type: question' 8 | assignees: '' 9 | --- 10 | 11 | **PLEASE READ** 12 | 13 | If you have a support contract with Google and questions related to how Navigation SDK works and its features should be used, please create an issue in the [support console](https://console.cloud.google.com/google/maps-apis/support/createcase). This will ensure a timely response. 14 | 15 | Links to the official native SDKs: 16 | - [Android](https://developers.google.com/maps/documentation/navigation/android-sdk) 17 | - [iOS](https://developers.google.com/maps/documentation/navigation/ios-sdk) 18 | 19 | Discover additional support services for the Google Maps Platform, including developer communities, technical guidance, and expert support at the Google Maps Platform [support resources page](https://developers.google.com/maps/support/). 20 | 21 | If your bug or feature request is not related to this particular library, please visit the Google Maps Platform [issue trackers](https://developers.google.com/maps/support/#issue_tracker). 22 | 23 | Check for answers on StackOverflow with the [google-maps](http://stackoverflow.com/questions/tagged/google-maps) tag. 24 | 25 | --- 26 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* 2 | 3 | *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* 4 | 5 | ## Pre-launch Checklist 6 | 7 | - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. 8 | - [ ] I signed the [CLA]. 9 | - [ ] I listed at least one issue that this PR fixes in the description above. 10 | - [ ] I updated/added relevant documentation 11 | - [ ] I added new tests to check the change I am making 12 | - [ ] All existing and new tests are passing. 13 | 14 | 15 | [Contributor Guide]: https://github.com/googlemaps/flutter-navigation-sdk/blob/main/CONTRIBUTING.md 16 | [CLA]: https://cla.developers.google.com/ -------------------------------------------------------------------------------- /.github/blunderbuss.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | assign_issues: 16 | - jokerttu 17 | assign_prs: 18 | - jokerttu 19 | - ArturoSalazarB16 20 | - caio1985 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | version: 2 16 | updates: 17 | - package-ecosystem: "pub" 18 | directory: "/" # Location of package manifests 19 | schedule: 20 | interval: "weekly" 21 | open-pull-requests-limit: 10 22 | commit-message: 23 | prefix: chore(deps) 24 | - package-ecosystem: "pub" 25 | directory: "/example" # Location of package manifests 26 | schedule: 27 | interval: "weekly" 28 | open-pull-requests-limit: 10 29 | commit-message: 30 | prefix: chore(deps) 31 | - package-ecosystem: "gradle" 32 | directory: "/android" # Location of package manifests 33 | schedule: 34 | interval: "weekly" 35 | open-pull-requests-limit: 10 36 | commit-message: 37 | prefix: chore(deps) 38 | - package-ecosystem: "gradle" 39 | directory: "/example/android" # Location of package manifests 40 | schedule: 41 | interval: "weekly" 42 | open-pull-requests-limit: 10 43 | commit-message: 44 | prefix: chore(deps) 45 | - package-ecosystem: "github-actions" 46 | directory: "/" # Location of package manifests 47 | schedule: 48 | interval: "weekly" 49 | open-pull-requests-limit: 10 50 | commit-message: 51 | prefix: chore(deps) 52 | -------------------------------------------------------------------------------- /.github/workflows/licence-check.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Check license headers 16 | on: 17 | pull_request: 18 | push: 19 | branches: 20 | - main 21 | 22 | concurrency: 23 | group: ${{ github.workflow }}-${{ github.ref }} 24 | cancel-in-progress: true 25 | 26 | jobs: 27 | check-files-license-headers: 28 | runs-on: ubuntu-latest 29 | timeout-minutes: 30 30 | steps: 31 | - name: Checkout code 32 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 33 | - name: Setup go 34 | uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed 35 | with: 36 | go-version: "^1.13.1" 37 | # Go is used by addlicense command (addlicense is used in melos run 38 | # check-license-header) 39 | - name: Run addlicense 40 | run: go install github.com/google/addlicense@latest 41 | - name: Install Flutter 42 | uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff 43 | with: 44 | flutter-version: "3.27.x" 45 | channel: "stable" 46 | cache: true 47 | - name: Install Melos 48 | uses: bluefireteam/melos-action@6085791af7036f6366c9a4b9d55105c0ef9c6388 49 | with: 50 | # Running `melos bootstrap` is not needed because we use Melos just 51 | # for the `check-license-header` script. 52 | run-bootstrap: false 53 | melos-version: "6.0.0" 54 | - name: Check license header 55 | run: melos run check-license-header 56 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # A workflow that publishes the library to CocoaPods 16 | name: Publish to pub.dev 17 | 18 | on: 19 | push: 20 | tags: 21 | - "[0-9]+.[0-9]+.[0-9]+" 22 | workflow_dispatch: # manually trigger if previous runs failed 23 | 24 | concurrency: 25 | group: publishing 26 | cancel-in-progress: true 27 | 28 | # Publish using the reusable workflow from dart-lang. 29 | jobs: 30 | publish: 31 | permissions: 32 | id-token: write # Required for authentication using OIDC 33 | uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 34 | -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | on: 16 | push: 17 | branches: 18 | - main 19 | 20 | concurrency: 21 | group: ${{ github.workflow }}-${{ github.ref }} 22 | cancel-in-progress: true 23 | 24 | permissions: 25 | contents: write 26 | pull-requests: write 27 | 28 | name: release-please 29 | 30 | jobs: 31 | release-please: 32 | runs-on: ubuntu-latest 33 | steps: 34 | - uses: googleapis/release-please-action@d1a8f221d7723166f48a584aebba00ef3f6febec 35 | with: 36 | token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} 37 | -------------------------------------------------------------------------------- /.github/workflows/scripts/validate-formatting.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2023 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | set -e 16 | 17 | if [[ $(git ls-files --modified) ]]; then 18 | echo "" 19 | echo "" 20 | echo "These files are not formatted correctly:" 21 | for f in $(git ls-files --modified); do 22 | echo "" 23 | echo "" 24 | echo "-----------------------------------------------------------------" 25 | echo "$f" 26 | echo "-----------------------------------------------------------------" 27 | echo "" 28 | git --no-pager diff --unified=0 --minimal $f 29 | echo "" 30 | echo "-----------------------------------------------------------------" 31 | echo "" 32 | echo "" 33 | done 34 | if [[ $GITHUB_WORKFLOW ]]; then 35 | git checkout . > /dev/null 2>&1 36 | fi 37 | echo "" 38 | echo "❌ Some files are incorrectly formatted, see above output." 39 | echo "" 40 | echo "To fix these locally, run: 'melos run format'." 41 | exit 1 42 | else 43 | echo "" 44 | echo "✅ All files are formatted correctly." 45 | fi 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | .DS_Store 3 | .atom/ 4 | .vscode/* 5 | .buildlog/ 6 | .history 7 | .melos_tool/* 8 | 9 | # IntelliJ related 10 | *.iml 11 | *.ipr 12 | *.iws 13 | .idea/ 14 | 15 | # vscode related 16 | .vscode 17 | .vscode/* 18 | !.vscode/tasks.json 19 | !.vscode/settings.json 20 | devtools_options.yaml 21 | 22 | # Flutter/Dart/Pub related 23 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 24 | pubspec.lock 25 | pubspec_overrides.yaml 26 | .dart_tool/ 27 | .packages 28 | build/ 29 | .flutter-plugins* 30 | .pub-cache/ 31 | .pub/ 32 | 33 | # Dart Docs 34 | **/doc/api/ 35 | 36 | # iOS 37 | Podfile.lock 38 | Pods/ 39 | .symlinks/ 40 | **/Flutter/ephemeral/ 41 | **/Flutter/Flutter.podspec 42 | **/Flutter/App.framework/ 43 | **/Flutter/Flutter.framework/ 44 | **/Flutter/Generated.xcconfig 45 | **/Flutter/flutter_assets/ 46 | ServiceDefinitions.json 47 | xcuserdata/ 48 | .swiftpm/ 49 | .last_build_id 50 | 51 | # Android 52 | local.properties 53 | keystore.properties 54 | .gradle/ 55 | gradlew 56 | gradlew.bat 57 | gradle-wrapper.jar 58 | 59 | .project 60 | .classpath 61 | .settings 62 | 63 | # Generated files on example apps 64 | flutter_export_environment.sh 65 | GeneratedPluginRegistrant.* 66 | generated_plugin_registrant.* 67 | 68 | # Patrol generated test files 69 | test_bundle.dart -------------------------------------------------------------------------------- /.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 and should not be manually edited. 5 | 6 | version: 7 | revision: "efbf63d9c66b9f6ec30e9ad4611189aa80003d31" 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: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 17 | base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 18 | - platform: android 19 | create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 20 | base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 21 | - platform: ios 22 | create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 23 | base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 24 | 25 | # User provided section 26 | 27 | # List of Local paths (relative to this file) that should be 28 | # ignored by the migrate tool. 29 | # 30 | # Files that are not part of the templates will be ignored by default. 31 | unmanaged_files: 32 | - 'lib/main.dart' 33 | - 'ios/Runner.xcodeproj/project.pbxproj' 34 | -------------------------------------------------------------------------------- /.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | ".": "0.6.1" 3 | } 4 | -------------------------------------------------------------------------------- /CARPLAY.MD: -------------------------------------------------------------------------------- 1 | # Navigation for Apple CarPlay 2 | 3 | This guide explains how to enable and integrate Apple CarPlay with the Flutter SDK. 4 | 5 | ## Requirements 6 | 7 | - iOS device or iOS simulator 8 | - CarPlay Simulator 9 | - CarPlay entitlement for your application (provided by Apple) 10 | 11 | ## Setup 12 | 13 | Refer to the [Apple CarPlay Developer Guide](https://developer.apple.com/carplay/) to understand how CarPlay works and to complete the initial setup. Key steps include: 14 | 15 | - Adding the CarPlay entitlement to your Xcode project. 16 | - Creating a separate scene for the CarPlay map and enabling support for multiple scenes. 17 | 18 | ### SceneDelegate for CarPlay 19 | 20 | Once your project is configured to support multiple scenes, and you are setting up a dedicated scene for CarPlay, you can leverage the `BaseCarSceneDelegate` provided by the SDK. This base class simplifies the setup by handling initialization, teardown, and rendering the map on the CarPlay display. 21 | 22 | Please refer to the `CarSceneDelegate.swift` file in the iOS example app for guidance. 23 | 24 | To customize the CarPlay experience, override the `getTemplate` method in your custom `CarSceneDelegate` class, providing your own `CPMapTemplate`: 25 | 26 | ```swift 27 | override func getTemplate() -> CPMapTemplate { 28 | let template = CPMapTemplate() 29 | template.showPanningInterface(animated: true) 30 | 31 | let button = CPBarButton(title: "Custom Event") { [weak self] _ in 32 | let data = ["sampleDataKey": "sampleDataContent"] 33 | self?.sendCustomNavigationAutoEvent(event: "CustomCarPlayEvent", data: data) 34 | } 35 | template.leadingNavigationBarButtons = [button] 36 | return template 37 | } 38 | ``` 39 | 40 | For advanced customization, you can bypass the base class and implement your own delegate inheriting `CPTemplateApplicationSceneDelegate`. You can use the provided `BaseCarSceneDelegate` base class as a reference on how to do that. 41 | 42 | ### Flutter Setup 43 | 44 | On the Flutter side, you can use the `GoogleMapsAutoViewController` to interface with the CarPlay instance. The `GoogleMapsAutoViewController` allows you to call map functions on the CarPlay map view, and you can manage listeners using the provided functions. 45 | 46 | ```dart 47 | final GoogleMapsAutoViewController _autoViewController = 48 | GoogleMapsAutoViewController(); 49 | 50 | _autoViewController.listenForCustomNavigationAutoEvents((event) { 51 | showMessage("Received event: ${event.event}"); 52 | }); 53 | 54 | Future _setMapTypeForAutoToSatellite() async { 55 | await _autoViewController.setMapType(mapType: MapType.satellite); 56 | } 57 | ``` 58 | 59 | For a more detailed example, refer to the `lib/pages/navigation.dart` file in the Flutter example application. 60 | 61 | ## Example Project 62 | 63 | For a fully functional CarPlay implementation, check out the [Runner](./example/ios/) Xcode project, which includes the `RunnerCarPlay` build target. The sample already contains test entitlement so you don't need to request one from Apple to run it. 64 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Specify analysis options. 16 | # 17 | # This file is a copy of analysis_options.yaml from flutter repo 18 | # as of 2022-07-27, but with some modifications marked with 19 | # "DIFFERENT FROM FLUTTER/FLUTTER" below. The file is expected to 20 | # be kept in sync with the master file from the flutter repo. 21 | 22 | include: package:flutter_lints/flutter.yaml 23 | 24 | analyzer: 25 | language: 26 | strict-casts: true 27 | strict-raw-types: true 28 | errors: 29 | # allow self-reference to deprecated members 30 | deprecated_member_use_from_same_package: ignore 31 | exclude: 32 | # Ignore generated files 33 | - "**/*.g.dart" 34 | - "**/*.mocks.dart" # Mockito @GenerateMocks 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/proguard.txt: -------------------------------------------------------------------------------- 1 | -dontwarn com.bumptech.glide.integration.cronet.ChromiumUrlLoader$StreamFactory 2 | -dontwarn com.bumptech.glide.integration.cronet.CronetRequestFactory 3 | -dontwarn com.bumptech.glide.integration.cronet.DataLogger -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | rootProject.name = 'google_navigation_flutter' 16 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 19 | 20 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/CircleBuilder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.CircleOptions 20 | import com.google.android.gms.maps.model.LatLng 21 | import com.google.android.gms.maps.model.PatternItem 22 | 23 | class CircleBuilder : CircleOptionsSink { 24 | private val _circleOptions: CircleOptions = CircleOptions() 25 | 26 | fun build(): CircleOptions { 27 | return _circleOptions 28 | } 29 | 30 | override fun setPosition(position: LatLng) { 31 | _circleOptions.center(position) 32 | } 33 | 34 | override fun setRadius(radius: Double) { 35 | _circleOptions.radius(radius) 36 | } 37 | 38 | override fun setStrokeColor(color: Int) { 39 | _circleOptions.strokeColor(color) 40 | } 41 | 42 | override fun setStrokeWidth(width: Float) { 43 | _circleOptions.strokeWidth(width) 44 | } 45 | 46 | override fun setStrokePattern(strokePattern: List) { 47 | _circleOptions.strokePattern(strokePattern) 48 | } 49 | 50 | override fun setFillColor(color: Int) { 51 | _circleOptions.fillColor(color) 52 | } 53 | 54 | override fun setZIndex(zIndex: Float) { 55 | _circleOptions.zIndex(zIndex) 56 | } 57 | 58 | override fun setVisible(visible: Boolean) { 59 | _circleOptions.visible(visible) 60 | } 61 | 62 | override fun setClickable(clickable: Boolean) { 63 | _circleOptions.clickable(clickable) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/CircleController.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.Circle 20 | import com.google.android.gms.maps.model.LatLng 21 | import com.google.android.gms.maps.model.PatternItem 22 | 23 | class CircleController(val circle: Circle, val circleId: String) : CircleOptionsSink { 24 | override fun setPosition(position: LatLng) { 25 | circle.center = position 26 | } 27 | 28 | override fun setRadius(radius: Double) { 29 | circle.radius = radius 30 | } 31 | 32 | override fun setStrokeWidth(width: Float) { 33 | circle.strokeWidth = width 34 | } 35 | 36 | override fun setStrokeColor(color: Int) { 37 | circle.strokeColor = color 38 | } 39 | 40 | override fun setStrokePattern(strokePattern: List) { 41 | circle.strokePattern = strokePattern 42 | } 43 | 44 | override fun setFillColor(color: Int) { 45 | circle.fillColor = color 46 | } 47 | 48 | override fun setZIndex(zIndex: Float) { 49 | circle.zIndex = zIndex 50 | } 51 | 52 | override fun setVisible(visible: Boolean) { 53 | circle.isVisible = visible 54 | } 55 | 56 | override fun setClickable(clickable: Boolean) { 57 | circle.isClickable = clickable 58 | } 59 | 60 | fun remove() { 61 | circle.remove() 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/CircleOptionsSink.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.LatLng 20 | import com.google.android.gms.maps.model.PatternItem 21 | 22 | interface CircleOptionsSink { 23 | fun setPosition(position: LatLng) 24 | 25 | fun setRadius(radius: Double) 26 | 27 | fun setStrokeWidth(width: Float) 28 | 29 | fun setStrokeColor(color: Int) 30 | 31 | fun setStrokePattern(strokePattern: List) 32 | 33 | fun setFillColor(color: Int) 34 | 35 | fun setZIndex(zIndex: Float) 36 | 37 | fun setVisible(visible: Boolean) 38 | 39 | fun setClickable(clickable: Boolean) 40 | } 41 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.content.Context 20 | import android.view.View 21 | import com.google.android.gms.maps.MapView 22 | import io.flutter.plugin.platform.PlatformView 23 | 24 | class GoogleMapView 25 | internal constructor( 26 | context: Context, 27 | mapOptions: MapOptions, 28 | viewId: Int, 29 | viewEventApi: ViewEventApi, 30 | private val viewRegistry: GoogleMapsViewRegistry, 31 | imageRegistry: ImageRegistry, 32 | ) : PlatformView, GoogleMapsBaseMapView(viewId, mapOptions, viewEventApi, imageRegistry) { 33 | private val _mapView: MapView = MapView(context, mapOptions.googleMapOptions) 34 | 35 | override fun getView(): View { 36 | return _mapView 37 | } 38 | 39 | init { 40 | // Call all of these three lifecycle functions in sequence to fully 41 | // initialize the map view. 42 | _mapView.onCreate(context.applicationInfo.metaData) 43 | _mapView.onStart() 44 | _mapView.onResume() 45 | 46 | viewRegistry.registerMapView(viewId, this) 47 | 48 | _mapView.getMapAsync { map -> 49 | setMap(map) 50 | initListeners() 51 | imageRegistry.mapViewInitializationComplete() 52 | mapReady() 53 | mapOptions.padding?.let { setPadding(it) } 54 | } 55 | } 56 | 57 | override fun dispose() { 58 | // When view is disposed, all of these lifecycle functions must be 59 | // called to properly dispose navigation view and prevent leaks. 60 | _mapView.onPause() 61 | _mapView.onStop() 62 | _mapView.onDestroy() 63 | 64 | viewRegistry.unregisterMapView(getViewId()) 65 | } 66 | 67 | override fun onStart() { 68 | _mapView.onStart() 69 | } 70 | 71 | override fun onResume() { 72 | _mapView.onResume() 73 | } 74 | 75 | override fun onStop() { 76 | _mapView.onStop() 77 | } 78 | 79 | override fun onPause() { 80 | _mapView.onPause() 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.view.View 20 | import com.google.android.gms.maps.GoogleMap 21 | import com.google.android.libraries.navigation.NavigationViewForAuto 22 | 23 | class GoogleMapsAutoMapView 24 | internal constructor( 25 | mapOptions: MapOptions, 26 | private val viewRegistry: GoogleMapsViewRegistry, 27 | imageRegistry: ImageRegistry, 28 | private val mapView: NavigationViewForAuto, 29 | private val map: GoogleMap, 30 | ) : GoogleMapsBaseMapView(null, mapOptions, null, imageRegistry) { 31 | override fun getView(): View { 32 | return mapView 33 | } 34 | 35 | init { 36 | setMap(map) 37 | initListeners() 38 | imageRegistry.mapViewInitializationComplete() 39 | viewRegistry.registerAndroidAutoView(this) 40 | mapReady() 41 | } 42 | 43 | // Handled by AndroidAutoBaseScreen. 44 | override fun onStart() {} 45 | 46 | // Handled by AndroidAutoBaseScreen. 47 | override fun onResume() {} 48 | 49 | // Handled by AndroidAutoBaseScreen. 50 | override fun onStop() {} 51 | 52 | // Handled by AndroidAutoBaseScreen. 53 | override fun onPause() {} 54 | } 55 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsImageRegistryMessageHandler.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | class GoogleMapsImageRegistryMessageHandler(private val imageRegistry: ImageRegistry) : 20 | ImageRegistryApi { 21 | override fun registerBitmapImage( 22 | imageId: String, 23 | bytes: ByteArray, 24 | imagePixelRatio: Double, 25 | width: Double?, 26 | height: Double?, 27 | ): ImageDescriptorDto { 28 | return imageRegistry.registerBitmapImage(imageId, bytes, imagePixelRatio, width, height) 29 | } 30 | 31 | override fun unregisterImage(imageDescriptor: ImageDescriptorDto) { 32 | imageDescriptor.registeredImageId?.let { imageRegistry.unregisterImage(it) } 33 | } 34 | 35 | override fun clearRegisteredImages() { 36 | imageRegistry.clearRegisteredImages() 37 | } 38 | 39 | override fun getRegisteredImages(): List { 40 | return imageRegistry.registeredImages.map { Convert.registeredImageToImageDescriptorDto(it) } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationInspectorHandler.kt: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package com.google.maps.flutter.navigation 16 | 17 | class GoogleMapsNavigationInspectorHandler(private val viewRegistry: GoogleMapsViewRegistry) : 18 | NavigationInspector { 19 | private fun manager(): GoogleMapsNavigationSessionManager { 20 | return GoogleMapsNavigationSessionManager.getInstance() 21 | } 22 | 23 | override fun isViewAttachedToSession(viewId: Long): Boolean { 24 | /// Is session exists, it's automatically attached to any existing view. 25 | if (viewRegistry.getNavigationView(viewId.toInt()) != null) { 26 | return manager().isInitialized() 27 | } 28 | return false 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsViewFactory.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.content.Context 20 | import io.flutter.plugin.common.StandardMessageCodec 21 | import io.flutter.plugin.platform.PlatformView 22 | import io.flutter.plugin.platform.PlatformViewFactory 23 | 24 | class GoogleMapsViewFactory( 25 | private val viewRegistry: GoogleMapsViewRegistry, 26 | private val viewEventApi: ViewEventApi, 27 | private val imageRegistry: ImageRegistry, 28 | ) : PlatformViewFactory(StandardMessageCodec.INSTANCE) { 29 | override fun create(context: Context, viewId: Int, args: Any?): PlatformView { 30 | val params = ViewCreationOptionsDto.fromList(args as List) 31 | val mapOptions = Convert.convertMapOptionsFromDto(params.mapOptions) 32 | if (params.mapViewType == MapViewTypeDto.NAVIGATION) { 33 | val navigationViewOptionsDto = 34 | params.navigationViewOptions?.let { Convert.convertNavigationViewOptionsFromDto(it) } 35 | return GoogleMapsNavigationView( 36 | context, 37 | mapOptions, 38 | navigationViewOptionsDto, 39 | viewId, 40 | viewRegistry, 41 | viewEventApi, 42 | imageRegistry, 43 | ) 44 | } else { 45 | return GoogleMapView(context, mapOptions, viewId, viewEventApi, viewRegistry, imageRegistry) 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/MapOptions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.GoogleMapOptions 20 | 21 | class MapOptions(val googleMapOptions: GoogleMapOptions, var padding: MapPaddingDto?) {} 22 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/MarkerBuilder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.LatLng 20 | import com.google.android.gms.maps.model.MarkerOptions 21 | 22 | /** Class that builds [MarkerOptions] instance */ 23 | class MarkerBuilder : MarkerOptionsSink { 24 | private val _markerOptions: MarkerOptions = MarkerOptions() 25 | var consumeTapEvents: Boolean = false 26 | private set 27 | 28 | fun build(): MarkerOptions { 29 | return _markerOptions 30 | } 31 | 32 | override fun setAlpha(alpha: Float) { 33 | _markerOptions.alpha(alpha) 34 | } 35 | 36 | override fun setAnchor(u: Float, v: Float) { 37 | _markerOptions.anchor(u, v) 38 | } 39 | 40 | override fun setDraggable(draggable: Boolean) { 41 | _markerOptions.draggable(draggable) 42 | } 43 | 44 | override fun setFlat(flat: Boolean) { 45 | _markerOptions.flat(flat) 46 | } 47 | 48 | override fun setConsumeTapEvents(consumeTapEvents: Boolean) { 49 | this.consumeTapEvents = consumeTapEvents 50 | } 51 | 52 | override fun setInfoWindowAnchor(u: Float, v: Float) { 53 | _markerOptions.infoWindowAnchor(u, v) 54 | } 55 | 56 | override fun setTitle(title: String?) { 57 | _markerOptions.title(title) 58 | } 59 | 60 | override fun setSnippet(snippet: String?) { 61 | _markerOptions.snippet(snippet) 62 | } 63 | 64 | override fun setPosition(position: LatLng) { 65 | _markerOptions.position(position) 66 | } 67 | 68 | override fun setRotation(rotation: Float) { 69 | _markerOptions.rotation(rotation) 70 | } 71 | 72 | override fun setVisible(visible: Boolean) { 73 | _markerOptions.visible(visible) 74 | } 75 | 76 | override fun setZIndex(zIndex: Float) { 77 | _markerOptions.zIndex(zIndex) 78 | } 79 | 80 | override fun setIcon(registeredImage: RegisteredImage?) { 81 | // registeredImage will be stored in the MarkerController object 82 | // after the marker has been created. 83 | if (registeredImage != null) { 84 | _markerOptions.icon(registeredImage.bitmapDescriptor) 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/MarkerOptionsSink.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.LatLng 20 | 21 | /** Interface for marker configuration options */ 22 | interface MarkerOptionsSink { 23 | fun setAlpha(alpha: Float) 24 | 25 | fun setAnchor(u: Float, v: Float) 26 | 27 | fun setConsumeTapEvents(consumeTapEvents: Boolean) 28 | 29 | fun setDraggable(draggable: Boolean) 30 | 31 | fun setFlat(flat: Boolean) 32 | 33 | fun setInfoWindowAnchor(u: Float, v: Float) 34 | 35 | fun setTitle(title: String?) 36 | 37 | fun setSnippet(snippet: String?) 38 | 39 | fun setPosition(position: LatLng) 40 | 41 | fun setRotation(rotation: Float) 42 | 43 | fun setVisible(visible: Boolean) 44 | 45 | fun setZIndex(zIndex: Float) 46 | 47 | fun setIcon(registeredImage: RegisteredImage?) 48 | } 49 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/NavigationViewConfiguration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | /** Determines the initial visibility of the navigation UI on map initialization. */ 20 | enum class NavigationUIEnabledPreference { 21 | /** Navigation UI gets enabled if the navigation session has been started. */ 22 | AUTOMATIC, 23 | 24 | /** Navigation UI is disabled. */ 25 | DISABLED, 26 | } 27 | 28 | /** Class for navigation view configuration options. */ 29 | data class NavigationViewOptions(val navigationUiEnabledPreference: NavigationUIEnabledPreference?) 30 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/PolygonBuilder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.LatLng 20 | import com.google.android.gms.maps.model.PolygonOptions 21 | 22 | class PolygonBuilder : PolygonOptionsSink { 23 | private val _polygonOptions: PolygonOptions = PolygonOptions() 24 | 25 | fun build(): PolygonOptions { 26 | return _polygonOptions 27 | } 28 | 29 | override fun setFillColor(color: Int) { 30 | _polygonOptions.fillColor(color) 31 | } 32 | 33 | override fun setStrokeColor(color: Int) { 34 | _polygonOptions.strokeColor(color) 35 | } 36 | 37 | override fun setGeodesic(geodesic: Boolean) { 38 | _polygonOptions.geodesic(geodesic) 39 | } 40 | 41 | override fun setPoints(points: List) { 42 | _polygonOptions.addAll(points) 43 | } 44 | 45 | override fun setHoles(holes: List>) { 46 | holes.forEach { _polygonOptions.addHole(it) } 47 | } 48 | 49 | override fun setVisible(visible: Boolean) { 50 | _polygonOptions.visible(visible) 51 | } 52 | 53 | override fun setStrokeWidth(width: Float) { 54 | _polygonOptions.strokeWidth(width) 55 | } 56 | 57 | override fun setZIndex(zIndex: Float) { 58 | _polygonOptions.zIndex(zIndex) 59 | } 60 | 61 | override fun setClickable(clickable: Boolean) { 62 | _polygonOptions.clickable(clickable) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/PolygonController.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.LatLng 20 | import com.google.android.gms.maps.model.Polygon 21 | 22 | class PolygonController(val polygon: Polygon, val polygonId: String) : PolygonOptionsSink { 23 | override fun setFillColor(color: Int) { 24 | polygon.fillColor = color 25 | } 26 | 27 | override fun setStrokeColor(color: Int) { 28 | polygon.strokeColor = color 29 | } 30 | 31 | override fun setGeodesic(geodesic: Boolean) { 32 | polygon.isGeodesic = geodesic 33 | } 34 | 35 | override fun setPoints(points: List) { 36 | polygon.points = points 37 | } 38 | 39 | override fun setHoles(holes: List>) { 40 | polygon.holes = holes 41 | } 42 | 43 | override fun setVisible(visible: Boolean) { 44 | polygon.isVisible = visible 45 | } 46 | 47 | override fun setStrokeWidth(width: Float) { 48 | polygon.strokeWidth = width 49 | } 50 | 51 | override fun setZIndex(zIndex: Float) { 52 | polygon.zIndex = zIndex 53 | } 54 | 55 | override fun setClickable(clickable: Boolean) { 56 | polygon.isClickable = clickable 57 | } 58 | 59 | fun remove() { 60 | polygon.remove() 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/PolygonOptionsSink.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.LatLng 20 | 21 | interface PolygonOptionsSink { 22 | fun setFillColor(color: Int) 23 | 24 | fun setStrokeColor(color: Int) 25 | 26 | fun setGeodesic(geodesic: Boolean) 27 | 28 | fun setPoints(points: List) 29 | 30 | fun setHoles(holes: List>) 31 | 32 | fun setVisible(visible: Boolean) 33 | 34 | fun setStrokeWidth(width: Float) 35 | 36 | fun setZIndex(zIndex: Float) 37 | 38 | fun setClickable(clickable: Boolean) 39 | } 40 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/PolylineBuilder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.LatLng 20 | import com.google.android.gms.maps.model.PatternItem 21 | import com.google.android.gms.maps.model.PolylineOptions 22 | import com.google.android.gms.maps.model.StyleSpan 23 | 24 | class PolylineBuilder : PolylineOptionsSink { 25 | private val _polylineOptions: PolylineOptions = PolylineOptions() 26 | 27 | fun build(): PolylineOptions { 28 | return _polylineOptions 29 | } 30 | 31 | override fun setStrokeColor(color: Int) { 32 | _polylineOptions.color(color) 33 | } 34 | 35 | override fun setGeodesic(geodesic: Boolean) { 36 | _polylineOptions.geodesic(geodesic) 37 | } 38 | 39 | override fun setPoints(points: List) { 40 | _polylineOptions.addAll(points) 41 | } 42 | 43 | override fun setVisible(visible: Boolean) { 44 | _polylineOptions.visible(visible) 45 | } 46 | 47 | override fun setStrokeWidth(width: Float) { 48 | _polylineOptions.width(width) 49 | } 50 | 51 | override fun setZIndex(zIndex: Float) { 52 | _polylineOptions.zIndex(zIndex) 53 | } 54 | 55 | override fun setClickable(clickable: Boolean) { 56 | _polylineOptions.clickable(clickable) 57 | } 58 | 59 | override fun setStrokeJointType(strokeJointType: Int) { 60 | _polylineOptions.jointType(strokeJointType) 61 | } 62 | 63 | override fun setStrokePattern(strokePattern: List) { 64 | _polylineOptions.pattern(strokePattern) 65 | } 66 | 67 | override fun setSpans(spans: List) { 68 | _polylineOptions.addAllSpans(spans) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/PolylineController.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.LatLng 20 | import com.google.android.gms.maps.model.PatternItem 21 | import com.google.android.gms.maps.model.Polyline 22 | import com.google.android.gms.maps.model.StyleSpan 23 | 24 | class PolylineController(val polyline: Polyline, val polylineId: String) : PolylineOptionsSink { 25 | 26 | override fun setStrokeColor(color: Int) { 27 | polyline.color = color 28 | } 29 | 30 | override fun setGeodesic(geodesic: Boolean) { 31 | polyline.isGeodesic = geodesic 32 | } 33 | 34 | override fun setPoints(points: List) { 35 | polyline.points = points 36 | } 37 | 38 | override fun setVisible(visible: Boolean) { 39 | polyline.isVisible = visible 40 | } 41 | 42 | override fun setStrokeWidth(width: Float) { 43 | polyline.width = width 44 | } 45 | 46 | override fun setZIndex(zIndex: Float) { 47 | polyline.zIndex = zIndex 48 | } 49 | 50 | override fun setClickable(clickable: Boolean) { 51 | polyline.isClickable = clickable 52 | } 53 | 54 | override fun setStrokeJointType(strokeJointType: Int) { 55 | polyline.jointType = strokeJointType 56 | } 57 | 58 | override fun setStrokePattern(strokePattern: List) { 59 | polyline.pattern = strokePattern 60 | } 61 | 62 | override fun setSpans(spans: List) { 63 | polyline.spans = spans 64 | } 65 | 66 | fun remove() { 67 | polyline.remove() 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/PolylineOptionsSink.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.LatLng 20 | import com.google.android.gms.maps.model.PatternItem 21 | import com.google.android.gms.maps.model.StyleSpan 22 | 23 | interface PolylineOptionsSink { 24 | fun setStrokeColor(color: Int) 25 | 26 | fun setGeodesic(geodesic: Boolean) 27 | 28 | fun setPoints(points: List) 29 | 30 | fun setVisible(visible: Boolean) 31 | 32 | fun setStrokeWidth(width: Float) 33 | 34 | fun setZIndex(zIndex: Float) 35 | 36 | fun setClickable(clickable: Boolean) 37 | 38 | fun setStrokeJointType(strokeJointType: Int) 39 | 40 | fun setStrokePattern(strokePattern: List) 41 | 42 | fun setSpans(spans: List) 43 | } 44 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/QueuedBitmap.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.graphics.Bitmap 20 | 21 | data class QueuedBitmap( 22 | val imageId: String, 23 | val bitmap: Bitmap, 24 | val imagePixelRatio: Double, 25 | val width: Double?, 26 | val height: Double?, 27 | ) 28 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/google/maps/flutter/navigation/RegisteredImage.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import com.google.android.gms.maps.model.BitmapDescriptor 20 | 21 | data class RegisteredImage( 22 | val imageId: String, 23 | val bitmapDescriptor: BitmapDescriptor, 24 | val imagePixelRatio: Double, 25 | val width: Double?, 26 | val height: Double?, 27 | ) 28 | -------------------------------------------------------------------------------- /android/src/test/kotlin/com/google/maps/flutter/navigation/CircleBuilderTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.graphics.Color 20 | import kotlin.test.assertEquals 21 | import org.junit.Test 22 | 23 | internal class CircleBuilderTest { 24 | @Test 25 | fun circleBuilder_returnsExpectedValue() { 26 | val optionsIn = 27 | CircleOptionsDto( 28 | position = LatLngDto(50.0, 60.0), 29 | radius = 10.0, 30 | clickable = true, 31 | fillColor = Color.BLACK.toLong(), 32 | strokeColor = Color.RED.toLong(), 33 | strokeWidth = 3.0, 34 | visible = true, 35 | strokePattern = emptyList(), 36 | zIndex = 5.0, 37 | ) 38 | val builder = CircleBuilder() 39 | Convert.sinkCircleOptions(optionsIn, builder, 1.0F) 40 | val optionsOut = builder.build() 41 | 42 | assertEquals(50.0, optionsOut.center.latitude) 43 | assertEquals(60.0, optionsOut.center.longitude) 44 | assertEquals(10.0, optionsOut.radius) 45 | assertEquals(true, optionsOut.isClickable) 46 | assertEquals(Color.BLACK, optionsOut.fillColor) 47 | assertEquals(Color.RED, optionsOut.strokeColor) 48 | assertEquals(emptyList(), optionsOut.strokePattern) 49 | assertEquals(3F, optionsOut.strokeWidth) 50 | assertEquals(true, optionsOut.isVisible) 51 | assertEquals(5F, optionsOut.zIndex) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /android/src/test/kotlin/com/google/maps/flutter/navigation/CircleControllerTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.graphics.Color 20 | import com.google.android.gms.maps.model.Circle 21 | import com.google.android.gms.maps.model.LatLng 22 | import io.mockk.impl.annotations.MockK 23 | import io.mockk.junit4.MockKRule 24 | import io.mockk.verify 25 | import org.junit.Rule 26 | import org.junit.Test 27 | 28 | internal class CircleControllerTest { 29 | @get:Rule val mockkRule = MockKRule(this) 30 | 31 | @MockK(relaxUnitFun = true) lateinit var circle: Circle 32 | 33 | @Test 34 | fun circleController_callsExpectedFunctions() { 35 | val optionsIn = 36 | CircleOptionsDto( 37 | position = LatLngDto(50.0, 60.0), 38 | radius = 10.0, 39 | clickable = true, 40 | fillColor = Color.BLACK.toLong(), 41 | strokePattern = emptyList(), 42 | strokeColor = Color.RED.toLong(), 43 | strokeWidth = 3.0, 44 | visible = true, 45 | zIndex = 5.0, 46 | ) 47 | val controller = CircleController(circle, "Circle_0") 48 | Convert.sinkCircleOptions(optionsIn, controller, 1.0F) 49 | 50 | verify { circle.center = LatLng(50.0, 60.0) } 51 | verify { circle.radius = 10.0 } 52 | verify { circle.isClickable = true } 53 | verify { circle.fillColor = Color.BLACK } 54 | verify { circle.strokePattern = emptyList() } 55 | verify { circle.strokeColor = Color.RED } 56 | verify { circle.strokeWidth = 3F } 57 | verify { circle.isVisible = true } 58 | verify { circle.zIndex = 5F } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /android/src/test/kotlin/com/google/maps/flutter/navigation/PolygonBuilderTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.graphics.Color 20 | import kotlin.test.assertEquals 21 | import org.junit.Test 22 | 23 | internal class PolygonBuilderTest { 24 | @Test 25 | fun polygonBuilder_returnsExpectedValue() { 26 | val optionsIn = 27 | PolygonOptionsDto( 28 | points = listOf(LatLngDto(50.0, 60.0)), 29 | holes = listOf(PolygonHoleDto(listOf(LatLngDto(70.0, 80.0)))), 30 | clickable = true, 31 | fillColor = Color.BLACK.toLong(), 32 | geodesic = true, 33 | strokeColor = Color.RED.toLong(), 34 | strokeWidth = 3.0, 35 | visible = true, 36 | zIndex = 5.0, 37 | ) 38 | val builder = PolygonBuilder() 39 | Convert.sinkPolygonOptions(optionsIn, builder, 1.0F) 40 | val optionsOut = builder.build() 41 | 42 | assertEquals(50.0, optionsOut.points[0].latitude) 43 | assertEquals(60.0, optionsOut.points[0].longitude) 44 | assertEquals(70.0, optionsOut.holes[0][0].latitude) 45 | assertEquals(80.0, optionsOut.holes[0][0].longitude) 46 | assertEquals(true, optionsOut.isClickable) 47 | assertEquals(Color.BLACK, optionsOut.fillColor) 48 | assertEquals(true, optionsOut.isGeodesic) 49 | assertEquals(Color.RED, optionsOut.strokeColor) 50 | assertEquals(3F, optionsOut.strokeWidth) 51 | assertEquals(true, optionsOut.isVisible) 52 | assertEquals(5F, optionsOut.zIndex) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /android/src/test/kotlin/com/google/maps/flutter/navigation/PolygonControllerTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.graphics.Color 20 | import com.google.android.gms.maps.model.LatLng 21 | import com.google.android.gms.maps.model.Polygon 22 | import io.mockk.impl.annotations.MockK 23 | import io.mockk.junit4.MockKRule 24 | import io.mockk.verify 25 | import org.junit.Rule 26 | import org.junit.Test 27 | 28 | internal class PolygonControllerTest { 29 | @get:Rule val mockkRule = MockKRule(this) 30 | 31 | @MockK(relaxUnitFun = true) lateinit var polygon: Polygon 32 | 33 | @Test 34 | fun polygonController_callsExpectedFunctions() { 35 | val optionsIn = 36 | PolygonOptionsDto( 37 | points = listOf(LatLngDto(50.0, 60.0)), 38 | holes = listOf(PolygonHoleDto(listOf(LatLngDto(70.0, 80.0)))), 39 | clickable = true, 40 | fillColor = Color.BLACK.toLong(), 41 | geodesic = true, 42 | strokeColor = Color.RED.toLong(), 43 | strokeWidth = 3.0, 44 | visible = true, 45 | zIndex = 5.0, 46 | ) 47 | val controller = PolygonController(polygon, "Polygon_0") 48 | Convert.sinkPolygonOptions(optionsIn, controller, 1.0F) 49 | 50 | verify { polygon.points = listOf(LatLng(50.0, 60.0)) } 51 | verify { polygon.holes = listOf(listOf(LatLng(70.0, 80.0))) } 52 | verify { polygon.isClickable = true } 53 | verify { polygon.fillColor = Color.BLACK } 54 | verify { polygon.isGeodesic = true } 55 | verify { polygon.strokeColor = Color.RED } 56 | verify { polygon.strokeWidth = 3F } 57 | verify { polygon.isVisible = true } 58 | verify { polygon.zIndex = 5F } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /android/src/test/kotlin/com/google/maps/flutter/navigation/PolylineBuilderTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.graphics.Color 20 | import kotlin.test.assertEquals 21 | import org.junit.Test 22 | 23 | internal class PolylineBuilderTest { 24 | @Test 25 | fun polylineBuilder_returnsExpectedValue() { 26 | val optionsIn = 27 | PolylineOptionsDto( 28 | points = listOf(LatLngDto(50.0, 60.0), LatLngDto(80.0, 90.0)), 29 | clickable = true, 30 | geodesic = true, 31 | strokeColor = Color.RED.toLong(), 32 | strokeWidth = 3.0, 33 | strokeJointType = StrokeJointTypeDto.DEFAULTJOINT, 34 | visible = true, 35 | strokePattern = emptyList(), 36 | zIndex = 5.0, 37 | spans = emptyList(), 38 | ) 39 | val builder = PolylineBuilder() 40 | Convert.sinkPolylineOptions(optionsIn, builder, 1.0F) 41 | val optionsOut = builder.build() 42 | 43 | assertEquals(50.0, optionsOut.points[0].latitude) 44 | assertEquals(60.0, optionsOut.points[0].longitude) 45 | assertEquals(80.0, optionsOut.points[1].latitude) 46 | assertEquals(90.0, optionsOut.points[1].longitude) 47 | assertEquals(true, optionsOut.isClickable) 48 | assertEquals(true, optionsOut.isGeodesic) 49 | assertEquals(Color.RED, optionsOut.color) 50 | assertEquals(emptyList(), optionsOut.pattern) 51 | assertEquals(3F, optionsOut.width) 52 | assertEquals(true, optionsOut.isVisible) 53 | assertEquals(5F, optionsOut.zIndex) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /android/src/test/kotlin/com/google/maps/flutter/navigation/PolylineControllerTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation 18 | 19 | import android.graphics.Color 20 | import com.google.android.gms.maps.model.JointType 21 | import com.google.android.gms.maps.model.LatLng 22 | import com.google.android.gms.maps.model.Polyline 23 | import io.mockk.impl.annotations.MockK 24 | import io.mockk.junit4.MockKRule 25 | import io.mockk.verify 26 | import org.junit.Rule 27 | import org.junit.Test 28 | 29 | internal class PolylineControllerTest { 30 | @get:Rule val mockkRule = MockKRule(this) 31 | 32 | @MockK(relaxUnitFun = true) lateinit var polyline: Polyline 33 | 34 | @Test 35 | fun polylineController_callsExpectedFunctions() { 36 | val optionsIn = 37 | PolylineOptionsDto( 38 | points = listOf(LatLngDto(50.0, 60.0), LatLngDto(80.0, 90.0)), 39 | clickable = true, 40 | geodesic = true, 41 | strokeColor = Color.RED.toLong(), 42 | strokeWidth = 3.0, 43 | strokeJointType = StrokeJointTypeDto.DEFAULTJOINT, 44 | visible = true, 45 | strokePattern = emptyList(), 46 | zIndex = 5.0, 47 | spans = emptyList(), 48 | ) 49 | val controller = PolylineController(polyline, "Polyline_0") 50 | Convert.sinkPolylineOptions(optionsIn, controller, 1.0F) 51 | 52 | verify { polyline.points = listOf(LatLng(50.0, 60.0), LatLng(80.0, 90.0)) } 53 | verify { polyline.isClickable = true } 54 | verify { polyline.isGeodesic = true } 55 | verify { polyline.color = Color.RED } 56 | verify { polyline.width = 3F } 57 | verify { polyline.jointType = JointType.DEFAULT } 58 | verify { polyline.pattern = emptyList() } 59 | verify { polyline.isVisible = true } 60 | verify { polyline.zIndex = 5F } 61 | verify { polyline.spans = emptyList() } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /dartdoc_options.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | dartdoc: 16 | categories: 17 | "Navigation": 18 | markdown: doc/navigation.md 19 | name: Navigation 20 | "Navigation View": 21 | markdown: doc/navigation-view.md 22 | name: Navigation View 23 | "Map View": 24 | markdown: doc/map-view.md 25 | name: Map View 26 | "Image Registry": 27 | markdown: doc/image-registry.md 28 | name: Image Registry 29 | categoryOrder: ["Navigation", "Navigation View", "Map View", "Image Registry"] 30 | showUndocumentedCategories: true 31 | nodoc: ['**/*.g.dart'] 32 | 33 | -------------------------------------------------------------------------------- /doc/image-registry.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/doc/image-registry.md -------------------------------------------------------------------------------- /doc/map-view.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/doc/map-view.md -------------------------------------------------------------------------------- /doc/navigation-view.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/doc/navigation-view.md -------------------------------------------------------------------------------- /doc/navigation.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/doc/navigation.md -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .build/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | .swiftpm/ 13 | migrate_working_dir/ 14 | 15 | # IntelliJ related 16 | *.iml 17 | *.ipr 18 | *.iws 19 | .idea/ 20 | 21 | # The .vscode folder contains launch configuration and tasks you configure in 22 | # VS Code which you may wish to be included in version control, so this line 23 | # is commented out by default. 24 | #.vscode/ 25 | 26 | # Flutter/Dart/Pub related 27 | **/doc/api/ 28 | **/ios/Flutter/.last_build_id 29 | .dart_tool/ 30 | .flutter-plugins 31 | .flutter-plugins-dependencies 32 | .packages 33 | .pub-cache/ 34 | .pub/ 35 | /build/ 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/android/app/src/androidTest/java/com/google/maps/flutter/navigation_example/MainActivityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation_example; 18 | 19 | import androidx.test.platform.app.InstrumentationRegistry; 20 | import org.junit.Test; 21 | import org.junit.runner.RunWith; 22 | import org.junit.runners.Parameterized; 23 | import org.junit.runners.Parameterized.Parameters; 24 | import pl.leancode.patrol.PatrolJUnitRunner; 25 | 26 | @RunWith(Parameterized.class) 27 | public class MainActivityTest { 28 | @Parameters(name = "{0}") 29 | public static Object[] testCases() { 30 | PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation(); 31 | instrumentation.setUp(MainActivity.class); 32 | instrumentation.waitForPatrolAppService(); 33 | return instrumentation.listDartTests(); 34 | } 35 | 36 | public MainActivityTest(String dartTestName) { 37 | this.dartTestName = dartTestName; 38 | } 39 | 40 | private final String dartTestName; 41 | 42 | @Test 43 | public void runDartTest() { 44 | PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation(); 45 | instrumentation.runDartTest(dartTestName); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/google/maps/flutter/navigation_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.maps.flutter.navigation_example 18 | 19 | import io.flutter.embedding.android.FlutterActivity 20 | 21 | class MainActivity: FlutterActivity() { 22 | } 23 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/google/maps/flutter/navigation_example/SampleAndroidAutoService.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.maps.flutter.navigation_example 17 | 18 | import androidx.car.app.CarAppService; 19 | import androidx.car.app.Session 20 | import androidx.car.app.SessionInfo 21 | import androidx.car.app.validation.HostValidator 22 | 23 | class SampleAndroidAutoService: CarAppService() { 24 | override fun createHostValidator(): HostValidator { 25 | // This sample allows all hosts to connect to the app. 26 | return HostValidator.ALLOW_ALL_HOSTS_VALIDATOR 27 | } 28 | 29 | override fun onCreateSession(sessionInfo: SessionInfo): Session { 30 | return SampleAndroidAutoSession(sessionInfo) 31 | } 32 | } -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 25 | 31 | 34 | 35 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 25 | 31 | 34 | 35 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/xml/automotive_app_desc.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | buildscript { 16 | ext.kotlin_version = '2.1.0' 17 | repositories { 18 | google() 19 | mavenCentral() 20 | } 21 | 22 | dependencies { 23 | classpath 'com.android.tools.build:gradle:8.6.1' 24 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 25 | classpath("com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1") 26 | } 27 | } 28 | 29 | allprojects { 30 | repositories { 31 | google() 32 | mavenCentral() 33 | } 34 | } 35 | 36 | rootProject.buildDir = '../build' 37 | subprojects { 38 | project.buildDir = "${rootProject.buildDir}/${project.name}" 39 | } 40 | subprojects { 41 | project.evaluationDependsOn(':app') 42 | } 43 | 44 | tasks.register("clean", Delete) { 45 | delete rootProject.buildDir 46 | } 47 | 48 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | org.gradle.jvmargs=-Xmx1536M 16 | android.useAndroidX=true 17 | android.enableJetifier=true 18 | android.nonTransitiveRClass=false 19 | android.nonFinalResIds=false 20 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Oct 11 17:27:19 CST 2024 2 | //=limitations under the License. 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | pluginManagement { 16 | def flutterSdkPath = { 17 | def properties = new Properties() 18 | file("local.properties").withInputStream { properties.load(it) } 19 | def flutterSdkPath = properties.getProperty("flutter.sdk") 20 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 21 | return flutterSdkPath 22 | } 23 | settings.ext.flutterSdkPath = flutterSdkPath() 24 | 25 | includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") 26 | 27 | plugins { 28 | id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false 29 | } 30 | } 31 | 32 | include ":app" 33 | 34 | apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" 35 | -------------------------------------------------------------------------------- /example/assets/2.0x/marker1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/example/assets/2.0x/marker1.png -------------------------------------------------------------------------------- /example/assets/marker1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/example/assets/marker1.png -------------------------------------------------------------------------------- /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/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 | UIRequiredDeviceCapabilities 24 | 25 | arm64 26 | 27 | MinimumOSVersion 28 | 12.0 29 | 30 | 31 | -------------------------------------------------------------------------------- /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/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.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.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import Flutter 16 | import GoogleMaps 17 | import GoogleNavigation 18 | import UIKit 19 | 20 | @objc class AppDelegate: FlutterAppDelegate { 21 | override func application( 22 | _ application: UIApplication, 23 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 24 | ) -> Bool { 25 | // 1. Try to find the Maps API key from the environment variables. 26 | // 2. Try to find the Maps API key from the Dart defines. 27 | // 3. Use the default Maps API key "YOUR_API_KEY". 28 | var mapsApiKey = 29 | ProcessInfo.processInfo.environment["MAPS_API_KEY"] ?? findMapApiKeyFromDartDefines( 30 | "MAPS_API_KEY") ?? "" 31 | if mapsApiKey.isEmpty { 32 | mapsApiKey = "YOUR_API_KEY" 33 | } 34 | GMSServices.provideAPIKey(mapsApiKey) 35 | GeneratedPluginRegistrant.register(with: self) 36 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 37 | } 38 | 39 | // Helper function to find the Maps API key from the Dart defines 40 | private func findMapApiKeyFromDartDefines(_ defineKey: String) -> String? { 41 | if Bundle.main.infoDictionary!["DART_DEFINES"] == nil { 42 | return nil 43 | } 44 | 45 | let dartDefinesString = Bundle.main.infoDictionary!["DART_DEFINES"] as! String 46 | let base64EncodedDartDefines = dartDefinesString.components(separatedBy: ",") 47 | for base64EncodedDartDefine in base64EncodedDartDefines { 48 | let decoded = String(data: Data(base64Encoded: base64EncodedDartDefine)!, encoding: .utf8)! 49 | let values = decoded.components(separatedBy: "=") 50 | if values[0] == defineKey && values.count == 2 { 51 | return values[1] 52 | } 53 | } 54 | return nil 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegateCarPlay.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import CarPlay 16 | import Flutter 17 | import GoogleMaps 18 | import GoogleNavigation 19 | import UIKit 20 | 21 | @objc class AppDelegateCarPlay: FlutterAppDelegate { 22 | override func application( 23 | _ application: UIApplication, 24 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 25 | ) -> Bool { 26 | // 1. Try to find the Maps API key from the environment variables. 27 | // 2. Try to find the Maps API key from the Dart defines. 28 | // 3. Use the default Maps API key "YOUR_API_KEY". 29 | var mapsApiKey = 30 | ProcessInfo.processInfo 31 | .environment["MAPS_API_KEY"] ?? findMapApiKeyFromDartDefines("MAPS_API_KEY") ?? "" 32 | if mapsApiKey.isEmpty { 33 | mapsApiKey = "YOUR_API_KEY" 34 | } 35 | GMSServices.provideAPIKey(mapsApiKey) 36 | return true 37 | } 38 | 39 | override func application( 40 | _ application: UIApplication, 41 | configurationForConnecting connectingSceneSession: UISceneSession, 42 | options: UIScene.ConnectionOptions 43 | ) -> UISceneConfiguration { 44 | if connectingSceneSession.role == .carTemplateApplication { 45 | let scene = UISceneConfiguration(name: "CarPlay", sessionRole: connectingSceneSession.role) 46 | scene.delegateClass = CarSceneDelegate.self 47 | return scene 48 | } else { 49 | let scene = UISceneConfiguration(name: "Phone", sessionRole: connectingSceneSession.role) 50 | scene.delegateClass = PhoneSceneDelegate.self 51 | return scene 52 | } 53 | } 54 | 55 | // Helper function to find the Maps API key from the Dart defines 56 | private func findMapApiKeyFromDartDefines(_ defineKey: String) -> String? { 57 | if Bundle.main.infoDictionary!["DART_DEFINES"] == nil { 58 | return nil 59 | } 60 | 61 | let dartDefinesString = Bundle.main.infoDictionary!["DART_DEFINES"] as! String 62 | let base64EncodedDartDefines = dartDefinesString.components(separatedBy: ",") 63 | for base64EncodedDartDefine in base64EncodedDartDefines { 64 | let decoded = String(data: Data(base64Encoded: base64EncodedDartDefine)!, encoding: .utf8)! 65 | let values = decoded.components(separatedBy: "=") 66 | if values[0] == defineKey, values.count == 2 { 67 | return values[1] 68 | } 69 | } 70 | return nil 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/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/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlemaps/flutter-navigation-sdk/42faf5bc73d840d4d6ae8c867063b34701f964e5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /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/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/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/ios/Runner/CarSceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import CarPlay 16 | import GoogleNavigation 17 | import UIKit 18 | import google_navigation_flutter 19 | 20 | class CarSceneDelegate: BaseCarSceneDelegate { 21 | override func getTemplate() -> CPMapTemplate { 22 | let template = CPMapTemplate() 23 | template.showPanningInterface(animated: true) 24 | 25 | let customEventButton = CPBarButton(title: "Custom Event") { [weak self] _ in 26 | let data = ["sampleDataKey": "sampleDataContent"] 27 | self?.sendCustomNavigationAutoEvent(event: "CustomCarPlayEvent", data: data) 28 | } 29 | let recenterButton = CPBarButton(title: "Re-center") { [weak self] _ in 30 | self?.getNavView()?.followMyLocation( 31 | perspective: GMSNavigationCameraPerspective.tilted, 32 | zoomLevel: nil 33 | ) 34 | } 35 | template.leadingNavigationBarButtons = [customEventButton, recenterButton] 36 | return template 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BGTaskSchedulerPermittedIdentifiers 6 | 7 | $(PRODUCT_BUNDLE_IDENTIFIER) 8 | 9 | CADisableMinimumFrameDurationOnPhone 10 | 11 | CFBundleDevelopmentRegion 12 | $(DEVELOPMENT_LANGUAGE) 13 | CFBundleDisplayName 14 | Google Maps Navigation 15 | CFBundleExecutable 16 | $(EXECUTABLE_NAME) 17 | CFBundleIdentifier 18 | $(PRODUCT_BUNDLE_IDENTIFIER) 19 | CFBundleInfoDictionaryVersion 20 | 6.0 21 | CFBundleName 22 | google_navigation_flutter_example 23 | CFBundlePackageType 24 | APPL 25 | CFBundleShortVersionString 26 | $(FLUTTER_BUILD_NAME) 27 | CFBundleSignature 28 | ???? 29 | CFBundleVersion 30 | $(FLUTTER_BUILD_NUMBER) 31 | DART_DEFINES 32 | $(DART_DEFINES) 33 | LSRequiresIPhoneOS 34 | 35 | NSLocationAlwaysAndWhenInUseUsageDescription 36 | Location needed for functionalities 37 | NSLocationUsageDescription 38 | Location needed for functionalities 39 | NSLocationWhenInUseUsageDescription 40 | Location needed for functionalities 41 | UIApplicationSupportsIndirectInputEvents 42 | 43 | UIBackgroundModes 44 | 45 | location 46 | processing 47 | remote-notification 48 | 49 | UILaunchStoryboardName 50 | LaunchScreen 51 | UIMainStoryboardFile 52 | Main 53 | UISupportedInterfaceOrientations 54 | 55 | UIInterfaceOrientationPortrait 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | UISupportedInterfaceOrientations~ipad 60 | 61 | UIInterfaceOrientationPortrait 62 | UIInterfaceOrientationPortraitUpsideDown 63 | UIInterfaceOrientationLandscapeLeft 64 | UIInterfaceOrientationLandscapeRight 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /example/ios/Runner/PhoneSceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import UIKit 16 | 17 | class PhoneSceneDelegate: UIResponder, UIWindowSceneDelegate { 18 | var window: UIWindow? 19 | 20 | func scene( 21 | _ scene: UIScene, willConnectTo session: UISceneSession, 22 | options connectionOptions: UIScene.ConnectionOptions 23 | ) { 24 | if let windowScene = scene as? UIWindowScene { 25 | window = UIWindow(windowScene: windowScene) 26 | let flutterEngine = FlutterEngine(name: "PhoneSceneDelegateEngine") 27 | flutterEngine.run() 28 | GeneratedPluginRegistrant.register(with: flutterEngine) 29 | let controller = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil) 30 | window?.rootViewController = controller 31 | window?.makeKeyAndVisible() 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import "GeneratedPluginRegistrant.h" 18 | -------------------------------------------------------------------------------- /example/ios/Runner/RunnerCarPlay.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.carplay-maps 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/main.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #if CARPLAY 16 | UIApplicationMain( 17 | CommandLine.argc, 18 | CommandLine.unsafeArgv, 19 | nil, 20 | NSStringFromClass(AppDelegateCarPlay.self) 21 | ) 22 | #else 23 | UIApplicationMain( 24 | CommandLine.argc, 25 | CommandLine.unsafeArgv, 26 | nil, 27 | NSStringFromClass(AppDelegate.self) 28 | ) 29 | #endif 30 | -------------------------------------------------------------------------------- /example/ios/RunnerUITests/RunnerUITests.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @import ObjectiveC.runtime; 18 | @import XCTest; 19 | @import patrol; 20 | 21 | PATROL_INTEGRATION_TEST_IOS_RUNNER(RunnerUITests) 22 | -------------------------------------------------------------------------------- /example/lib/pages/pages.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export 'camera.dart'; 16 | export 'map.dart'; 17 | export 'markers.dart'; 18 | export 'multiple_views.dart'; 19 | export 'navigation.dart'; 20 | export 'navigation_without_map.dart'; 21 | export 'polygons.dart'; 22 | export 'polylines.dart'; 23 | export 'turn_by_turn.dart'; 24 | export 'widget_initialization.dart'; 25 | -------------------------------------------------------------------------------- /example/lib/utils/constants.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /// Minimum zoom level to use for zoom options. 16 | /// 17 | /// Effective zoom level can change depending on map type and device used. 18 | const double googleMapsMinZoomLevel = 2; 19 | 20 | /// Maximum zoom level to use for zoom options. 21 | /// 22 | /// Effective zoom level can change depending on map type and device used. 23 | const double googleMapsMaxZoomLevel = 21; 24 | -------------------------------------------------------------------------------- /example/lib/utils/location_permissions.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // ignore_for_file: public_member_api_docs 16 | 17 | import 'package:permission_handler/permission_handler.dart'; 18 | 19 | Future requestLocationDialogAcceptance() async { 20 | return (await Permission.locationWhenInUse.isGranted) || 21 | (await Permission.locationWhenInUse.request()) == 22 | PermissionStatus.granted; 23 | } 24 | -------------------------------------------------------------------------------- /example/lib/utils/overlay_options.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import 'dart:io'; 16 | 17 | import 'package:flutter/material.dart'; 18 | 19 | /// Builds options button Widget for the example app. 20 | Widget getOptionsButton( 21 | BuildContext context, { 22 | required void Function()? onPressed, 23 | ButtonStyle? style, 24 | }) => 25 | ElevatedButton.icon( 26 | style: style ?? ElevatedButton.styleFrom(minimumSize: const Size(80, 36)), 27 | icon: const Icon(Icons.settings), 28 | onPressed: onPressed, 29 | label: const Text('Options'), 30 | ); 31 | 32 | /// Builds options button Widget with positioned alignment for the example app. 33 | Widget getOverlayOptionsButton(BuildContext context, 34 | {required void Function()? onPressed, ButtonStyle? style}) => 35 | SafeArea( 36 | child: Align( 37 | alignment: 38 | Platform.isAndroid ? Alignment.bottomCenter : Alignment.bottomRight, 39 | child: Padding( 40 | padding: const EdgeInsets.all(10), 41 | child: getOptionsButton(context, onPressed: onPressed, style: style), 42 | ), 43 | ), 44 | ); 45 | -------------------------------------------------------------------------------- /example/lib/utils/remaining_distance.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // ignore_for_file: public_member_api_docs 16 | 17 | String formatRemainingDistance(int meters) { 18 | if (meters >= 1000) { 19 | final double kilometers = meters / 1000; 20 | // Using toStringAsFixed to round to 1 decimal place for kilometers. 21 | return '${kilometers.toStringAsFixed(1)} km'; 22 | } else { 23 | return '$meters m'; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example/lib/utils/remaining_time.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // ignore_for_file: public_member_api_docs 16 | 17 | String formatRemainingDuration(Duration duration) { 18 | // Get total number of hours, minutes, and seconds. 19 | final int hours = duration.inHours; 20 | final int minutes = duration.inMinutes.remainder(60); 21 | final int seconds = duration.inSeconds.remainder(60); 22 | 23 | // Build the output based on the conditions. 24 | if (hours > 0) { 25 | // When hours are present, format as "HH:MM". 26 | return '$hours hours $minutes minutes'; 27 | } else if (minutes > 5) { 28 | // Otherwise, format as "MM" minutes. 29 | return '$minutes minutes'; 30 | } else if (minutes > 0) { 31 | // When there are fewer than 5 minutes, format as "MM:SS". 32 | return '$minutes minutes $seconds seconds'; 33 | } else { 34 | // When there are fewer than 1 minutes, format as "SS". 35 | return '$seconds seconds'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /example/lib/utils/snackbar.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // ignore_for_file: public_member_api_docs 16 | 17 | import 'package:flutter/material.dart'; 18 | 19 | void showSnackBarMessage(BuildContext context, String message, 20 | {bool removePrevious = true}) { 21 | final ScaffoldMessengerState scaffoldMessenger = 22 | ScaffoldMessenger.of(context); 23 | 24 | if (removePrevious) { 25 | scaffoldMessenger.removeCurrentSnackBar(); 26 | } 27 | 28 | scaffoldMessenger.showSnackBar( 29 | SnackBar(content: Text(message)), 30 | ); 31 | } 32 | 33 | void hideSnackBarMessage(BuildContext context) => 34 | ScaffoldMessenger.of(context)..hideCurrentSnackBar(); 35 | -------------------------------------------------------------------------------- /example/lib/utils/terms_of_service.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // ignore_for_file: public_member_api_docs 16 | 17 | import 'package:google_navigation_flutter/google_navigation_flutter.dart'; 18 | 19 | Future requestTermsAndConditionsAcceptance() async { 20 | return (await GoogleMapsNavigator.areTermsAccepted()) || 21 | (await GoogleMapsNavigator.showTermsAndConditionsDialog( 22 | 'Example title', 23 | 'Example company', 24 | )); 25 | } 26 | -------------------------------------------------------------------------------- /example/lib/utils/utils.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export 'constants.dart'; 16 | export 'location_permissions.dart'; 17 | export 'overlay_options.dart'; 18 | export 'remaining_distance.dart'; 19 | export 'remaining_time.dart'; 20 | export 'snackbar.dart'; 21 | export 'terms_of_service.dart'; 22 | export 'waypoint_marker.dart'; 23 | -------------------------------------------------------------------------------- /example/lib/widgets/dropdown_button.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // ignore_for_file: public_member_api_docs 16 | 17 | import 'package:flutter/material.dart'; 18 | 19 | class ExampleDropdownButton extends StatelessWidget { 20 | const ExampleDropdownButton({ 21 | super.key, 22 | required this.value, 23 | required this.items, 24 | required this.title, 25 | this.onChanged, 26 | }); 27 | 28 | final T value; 29 | final List items; 30 | final ValueChanged? onChanged; 31 | final String title; 32 | 33 | @override 34 | Widget build(BuildContext context) { 35 | return ListTile( 36 | title: Text(title), 37 | trailing: DropdownButton( 38 | value: value, 39 | items: items.map>((T value) { 40 | return DropdownMenuItem( 41 | value: value, 42 | child: Text(value.toString().split('.').last), 43 | ); 44 | }).toList(), 45 | onChanged: onChanged, 46 | ), 47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /example/lib/widgets/slider_editor.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // ignore_for_file: public_member_api_docs 16 | 17 | import 'package:flutter/material.dart'; 18 | 19 | class ExampleSlider extends StatelessWidget { 20 | const ExampleSlider({ 21 | super.key, 22 | required this.value, 23 | required this.onChanged, 24 | required this.title, 25 | required this.min, 26 | required this.max, 27 | this.fractionDigits, 28 | this.unit, 29 | }); 30 | 31 | final double value; 32 | final ValueChanged onChanged; 33 | final String title; 34 | final double min; 35 | final double max; 36 | final int? fractionDigits; 37 | final String? unit; 38 | 39 | @override 40 | Widget build(BuildContext context) { 41 | return Column( 42 | crossAxisAlignment: CrossAxisAlignment.start, 43 | children: [ 44 | ListTile( 45 | title: Text(title), 46 | trailing: 47 | Text(value.toStringAsFixed(fractionDigits ?? 1) + (unit ?? '')), 48 | ), 49 | Slider( 50 | value: value, 51 | onChanged: (double newValue) { 52 | onChanged(newValue); 53 | }, 54 | min: min, 55 | max: max, 56 | ), 57 | ], 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /example/lib/widgets/switch.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // ignore_for_file: public_member_api_docs 16 | 17 | import 'package:flutter/material.dart'; 18 | 19 | class ExampleSwitch extends StatefulWidget { 20 | const ExampleSwitch({ 21 | super.key, 22 | required this.title, 23 | this.onChanged, 24 | required this.initialValue, 25 | }); 26 | 27 | /// The title of the switch tile which is displayed next to the switch. 28 | final String title; 29 | 30 | /// Called when the user toggles the switch. 31 | /// 32 | /// If null, the switch will be disabled. 33 | final ValueChanged? onChanged; 34 | 35 | /// The initial value of the switch. 36 | final bool initialValue; 37 | 38 | @override 39 | State createState() => _ExampleSwitchState(); 40 | } 41 | 42 | class _ExampleSwitchState extends State { 43 | late bool _flag; 44 | 45 | @override 46 | void initState() { 47 | super.initState(); 48 | _flag = widget.initialValue; 49 | } 50 | 51 | void _toggleFlag(bool value) { 52 | setState(() { 53 | _flag = value; 54 | }); 55 | if (widget.onChanged != null) { 56 | widget.onChanged!(value); 57 | } 58 | } 59 | 60 | @override 61 | Widget build(BuildContext context) { 62 | return SwitchListTile( 63 | title: Text(widget.title), 64 | value: _flag, 65 | onChanged: widget.onChanged != null ? _toggleFlag : null, 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/lib/widgets/widgets.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export 'camera_position_editor.dart'; 16 | export 'dropdown_button.dart'; 17 | export 'latlng_bound_editor.dart'; 18 | export 'latlng_editor.dart'; 19 | export 'page.dart'; 20 | export 'slider_editor.dart'; 21 | export 'switch.dart'; 22 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: google_navigation_flutter_example 16 | description: Demonstrates how to use the google_navigation_flutter plugin. 17 | publish_to: "none" 18 | 19 | environment: 20 | sdk: ^3.4.0 21 | 22 | dependencies: 23 | cupertino_icons: ^1.0.2 24 | device_info_plus: ^11.3.0 25 | flutter: 26 | sdk: flutter 27 | google_navigation_flutter: 28 | path: ../ 29 | http: ^1.1.2 30 | permission_handler: ^11.3.1 31 | 32 | dev_dependencies: 33 | flutter_lints: ^4.0.0 34 | flutter_test: 35 | sdk: flutter 36 | integration_test: 37 | sdk: flutter 38 | meta: any 39 | patrol: 3.14.1 # Patrol 3.15.1 has hang issues on Android. Pinging to 3.14.1 for now. 40 | pub_semver: ^2.1.4 41 | test_api: any 42 | 43 | flutter: 44 | uses-material-design: true 45 | assets: 46 | - assets/night_style.json 47 | - assets/sepia_style.json 48 | - assets/marker1.png 49 | 50 | patrol: 51 | app_name: Navigation Example 52 | android: 53 | package_name: com.google.maps.flutter.navigation_example 54 | ios: 55 | bundle_id: com.google.maps.flutter.navigationExample 56 | -------------------------------------------------------------------------------- /header_template.txt: -------------------------------------------------------------------------------- 1 | Copyright {{.Year}} Google LLC 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | https://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /ios/google_navigation_flutter.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint google_navigation_flutter.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'google_navigation_flutter' 7 | s.version = '0.0.1' 8 | s.summary = 'A Google Maps Navigation Flutter plugin.' 9 | s.description = <<-DESC 10 | A Google Maps Navigation Flutter plugin. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Google Maps' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'google_navigation_flutter/Sources/google_navigation_flutter/**/*.swift' 17 | s.dependency 'Flutter' 18 | s.dependency 'GoogleNavigation', '9.4.0' 19 | s.platform = :ios, '15.0' 20 | s.static_framework = true 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 | s.resource_bundles = {'google_navigation_flutter_privacy_info' => ['google_navigation_flutter/Sources/google_navigation_flutter/PrivacyInfo.xcprivacy']} 26 | end 27 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.9 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | // Copyright 2024 Google LLC 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // https://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | import PackageDescription 19 | 20 | let package = Package( 21 | name: "google_navigation_flutter", 22 | platforms: [ 23 | .iOS("15.0") 24 | ], 25 | products: [ 26 | .library(name: "google-navigation-flutter", targets: ["google_navigation_flutter"]) 27 | ], 28 | dependencies: [ 29 | .package( 30 | url: "https://github.com/googlemaps/ios-navigation-sdk", 31 | exact: "9.4.0" 32 | ), 33 | .package( 34 | url: "https://github.com/googlemaps/ios-maps-sdk", 35 | exact: "9.4.0" 36 | ), 37 | ], 38 | targets: [ 39 | .target( 40 | name: "google_navigation_flutter", 41 | dependencies: [ 42 | .product( 43 | name: "GoogleNavigation", 44 | package: "ios-navigation-sdk" 45 | ), 46 | .product( 47 | name: "GoogleMaps", 48 | package: "ios-maps-sdk" 49 | ), 50 | ], 51 | resources: [ 52 | .process("PrivacyInfo.xcprivacy") 53 | ] 54 | ) 55 | ] 56 | ) 57 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert+MapConfiguration.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import Foundation 16 | import GoogleMaps 17 | 18 | extension Convert { 19 | static func convertNavigationUIEnabledPreference(preference: NavigationUIEnabledPreferenceDto?) 20 | -> NavigationUIEnabledPreference 21 | { 22 | switch preference { 23 | case .automatic: 24 | return .automatic 25 | case .disabled: 26 | return .disabled 27 | default: 28 | return .disabled 29 | } 30 | } 31 | 32 | static func convertMapOptions(_ mapOptions: MapOptionsDto) 33 | -> MapConfiguration 34 | { 35 | let cameraTargetBounds: GMSCoordinateBounds? 36 | if let bounds = mapOptions.cameraTargetBounds { 37 | cameraTargetBounds = convertLatLngBounds(bounds: bounds) 38 | } else { 39 | cameraTargetBounds = nil 40 | } 41 | 42 | return MapConfiguration( 43 | cameraPosition: convertCameraPosition(position: mapOptions.cameraPosition), 44 | mapType: convertMapType(mapType: mapOptions.mapType), 45 | compassEnabled: mapOptions.compassEnabled, 46 | rotateGesturesEnabled: mapOptions.rotateGesturesEnabled, 47 | scrollGesturesEnabled: mapOptions.scrollGesturesEnabled, 48 | tiltGesturesEnabled: mapOptions.tiltGesturesEnabled, 49 | zoomGesturesEnabled: mapOptions.zoomGesturesEnabled, 50 | scrollGesturesEnabledDuringRotateOrZoom: mapOptions.scrollGesturesEnabledDuringRotateOrZoom, 51 | cameraTargetBounds: cameraTargetBounds, 52 | minZoomPreference: mapOptions.minZoomPreference.map { Float($0) }, 53 | maxZoomPreference: mapOptions.maxZoomPreference.map { Float($0) }, 54 | padding: UIEdgeInsets( 55 | top: CGFloat(mapOptions.padding?.top ?? 0), 56 | left: CGFloat(mapOptions.padding?.left ?? 0), 57 | bottom: CGFloat(mapOptions.padding?.bottom ?? 0), 58 | right: CGFloat(mapOptions.padding?.right ?? 0) 59 | ) 60 | ) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/GMSCircle+Util.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import Foundation 16 | import GoogleMaps 17 | 18 | extension GMSCircle { 19 | static let circleKey = "circleId" 20 | 21 | func setCircleId(_ id: String) { 22 | userData = [Self.circleKey: id] 23 | } 24 | 25 | func getCircleId() -> String { 26 | (userData as? [String: String])?[Self.circleKey] ?? "" 27 | } 28 | 29 | /// Update [GMSCircle] instance with values from pigeon circle class 30 | func update(from pigeonCircle: CircleDto) { 31 | position = CLLocationCoordinate2D( 32 | latitude: pigeonCircle.options.position.latitude, 33 | longitude: pigeonCircle.options.position.longitude 34 | ) 35 | radius = pigeonCircle.options.radius 36 | strokeColor = UIColor(from: pigeonCircle.options.strokeColor) 37 | strokeWidth = pigeonCircle.options.strokeWidth 38 | fillColor = UIColor(from: pigeonCircle.options.fillColor) 39 | isTappable = pigeonCircle.options.clickable 40 | zIndex = Int32(pigeonCircle.options.zIndex) 41 | } 42 | 43 | func toPigeonCircle() -> CircleDto { 44 | let options = CircleOptionsDto( 45 | position: LatLngDto(latitude: position.latitude, longitude: position.longitude), 46 | radius: radius, 47 | strokeWidth: strokeWidth, 48 | strokeColor: strokeColor?.toRgb() ?? UIColor.black.toRgb()!, 49 | strokePattern: [], 50 | fillColor: fillColor?.toRgb() ?? UIColor.black.toRgb()!, 51 | zIndex: Double(zIndex), 52 | visible: map != nil, 53 | clickable: isTappable 54 | ) 55 | return CircleDto(circleId: getCircleId(), options: options) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/GMSPath+Util.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import Foundation 16 | import GoogleMaps 17 | 18 | extension GMSPath { 19 | func toLatLngDtos() -> [LatLngDto] { 20 | (0.. String { 26 | (userData as? [String: String])?[Self.polygonKey] ?? "" 27 | } 28 | 29 | /// Update [GMSPolygon] instance with values from pigeon polygon class 30 | func update(from pigeonPolygon: PolygonDto) { 31 | let newPath = GMSMutablePath() 32 | pigeonPolygon.options.points.compactMap { $0 }.forEach { point in 33 | newPath.addLatitude(point.latitude, longitude: point.longitude) 34 | } 35 | path = newPath 36 | 37 | let paths = pigeonPolygon.options.holes.compactMap { $0 }.map { hole in 38 | let path = GMSMutablePath() 39 | hole.points.compactMap { $0 }.forEach { point in 40 | path.addLatitude(point.latitude, longitude: point.longitude) 41 | } 42 | return path 43 | } 44 | holes = paths 45 | 46 | isTappable = pigeonPolygon.options.clickable 47 | fillColor = UIColor(from: pigeonPolygon.options.fillColor) 48 | geodesic = pigeonPolygon.options.geodesic 49 | strokeColor = UIColor(from: pigeonPolygon.options.strokeColor) 50 | strokeWidth = pigeonPolygon.options.strokeWidth 51 | zIndex = Int32(pigeonPolygon.options.zIndex) 52 | } 53 | 54 | func toPigeonPolygon() -> PolygonDto { 55 | let options = PolygonOptionsDto( 56 | points: path?.toLatLngDtos() ?? [], 57 | holes: holes?.map { PolygonHoleDto(points: $0.toLatLngDtos()) } ?? [], 58 | clickable: isTappable, 59 | fillColor: fillColor?.toRgb() ?? UIColor.black.toRgb()!, 60 | geodesic: geodesic, 61 | strokeColor: strokeColor?.toRgb() ?? UIColor.black.toRgb()!, 62 | strokeWidth: strokeWidth, 63 | visible: map != nil, 64 | zIndex: Double(zIndex) 65 | ) 66 | return PolygonDto(polygonId: getPolygonId(), options: options) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsImageRegistryMessageHandler.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import Flutter 16 | import Foundation 17 | 18 | class GoogleMapsImageRegistryMessageHandler: ImageRegistryApi { 19 | let imageRegistry: ImageRegistry 20 | 21 | init(imageRegistry: ImageRegistry) { 22 | self.imageRegistry = imageRegistry 23 | } 24 | 25 | func registerBitmapImage( 26 | imageId: String, bytes: FlutterStandardTypedData, 27 | imagePixelRatio: Double, 28 | width: Double?, 29 | height: Double? 30 | ) throws -> ImageDescriptorDto { 31 | try imageRegistry.registerBitmapImage( 32 | imageId: imageId, 33 | bytes: bytes.data, 34 | imagePixelRatio: imagePixelRatio, 35 | width: width, 36 | height: height 37 | ) 38 | } 39 | 40 | func unregisterImage(imageDescriptor: ImageDescriptorDto) throws { 41 | if let registeredImageId = imageDescriptor.registeredImageId { 42 | imageRegistry.unregisterImage(imageId: registeredImageId) 43 | } 44 | } 45 | 46 | func getRegisteredImages() throws -> [ImageDescriptorDto] { 47 | imageRegistry.registeredImages.map { $0.toImageDescriptorDto() } 48 | } 49 | 50 | func clearRegisteredImages() throws { 51 | imageRegistry.clearRegisteredImages() 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationInspectorHandler.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import Foundation 16 | 17 | class GoogleMapsNavigationInspectorHandler: NavigationInspector { 18 | private let _viewRegistry: GoogleMapsNavigationViewRegistry 19 | init(viewRegistry: GoogleMapsNavigationViewRegistry) { 20 | _viewRegistry = viewRegistry 21 | } 22 | 23 | func isViewAttachedToSession(viewId: Int64) throws -> Bool { 24 | guard let view = _viewRegistry.getView(viewId: viewId) else { 25 | throw GoogleMapsNavigationViewHandlerError.viewNotFound 26 | } 27 | return view.isAttachedToSession 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewFactory.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import Flutter 16 | import UIKit 17 | 18 | class GoogleMapsNavigationViewFactory: NSObject, FlutterPlatformViewFactory { 19 | private var viewRegistry: GoogleMapsNavigationViewRegistry 20 | private var viewEventApi: ViewEventApi 21 | private var imageRegistry: ImageRegistry 22 | 23 | init( 24 | viewRegistry: GoogleMapsNavigationViewRegistry, 25 | viewEventApi: ViewEventApi, imageRegistry: ImageRegistry 26 | ) { 27 | self.viewRegistry = viewRegistry 28 | self.viewEventApi = viewEventApi 29 | self.imageRegistry = imageRegistry 30 | super.init() 31 | } 32 | 33 | public func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol { 34 | FlutterStandardMessageCodec.sharedInstance() 35 | } 36 | 37 | func create( 38 | withFrame frame: CGRect, 39 | viewIdentifier viewId: Int64, 40 | arguments args: Any? 41 | ) -> FlutterPlatformView { 42 | guard let argsList = args as? [Any?], 43 | let params = ViewCreationOptionsDto.fromList(argsList) 44 | else { 45 | fatalError("Failed to decode ViewCreationOptionsDto") 46 | } 47 | 48 | let mapConfiguration = Convert.convertMapOptions(params.mapOptions) 49 | 50 | let isNavigationView = params.mapViewType == MapViewTypeDto.navigation 51 | 52 | return GoogleMapsNavigationView( 53 | frame: frame, 54 | viewIdentifier: viewId, 55 | isNavigationView: isNavigationView, 56 | viewRegistry: viewRegistry, 57 | viewEventApi: viewEventApi, 58 | navigationUIEnabledPreference: 59 | Convert 60 | .convertNavigationUIEnabledPreference( 61 | preference: params.navigationViewOptions? 62 | .navigationUIEnabledPreference), 63 | mapConfiguration: mapConfiguration, 64 | imageRegistry: imageRegistry, 65 | isCarPlayView: false 66 | ) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/ImageRegistry.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import UIKit 16 | 17 | enum GoogleMapsImageRegistryError: Error { 18 | case imageDecodingFailed 19 | } 20 | 21 | class ImageRegistry { 22 | var registeredImages: [RegisteredImage] = [] 23 | 24 | func registerBitmapImage( 25 | imageId: String, bytes: Data, imagePixelRatio: Double, width: Double?, 26 | height: Double? 27 | ) throws -> ImageDescriptorDto { 28 | guard var image = UIImage(data: bytes, scale: imagePixelRatio) else { 29 | throw GoogleMapsImageRegistryError.imageDecodingFailed 30 | } 31 | 32 | if width != nil, height != nil { 33 | image = ImageResizer.resize( 34 | image: image, 35 | size: CGSize(width: CGFloat(width!), height: CGFloat(height!)) 36 | ) 37 | } else if width != nil { 38 | image = ImageResizer.resize(image: image, width: CGFloat(width!)) 39 | } else if height != nil { 40 | image = ImageResizer.resize(image: image, height: CGFloat(height!)) 41 | } 42 | 43 | registeredImages.append( 44 | RegisteredImage( 45 | imageId: imageId, 46 | image: image, 47 | imagePixelRatio: imagePixelRatio, 48 | width: width, 49 | height: height 50 | )) 51 | return ImageDescriptorDto( 52 | registeredImageId: imageId, 53 | imagePixelRatio: imagePixelRatio, 54 | width: width, 55 | height: height 56 | ) 57 | } 58 | 59 | func findRegisteredImage(imageId: String) -> RegisteredImage? { 60 | registeredImages.first(where: { $0.imageId == imageId }) 61 | } 62 | 63 | func unregisterImage(imageId: String) { 64 | registeredImages.removeAll(where: { $0.imageId == imageId }) 65 | } 66 | 67 | func clearRegisteredImages() { 68 | registeredImages.removeAll() 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/ImageResizer.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import UIKit 16 | 17 | enum ImageResizer { 18 | static func resize(image: UIImage, width: CGFloat) -> UIImage { 19 | let height = (width / image.size.width) * image.size.height 20 | return resize(image: image, size: CGSize(width: width, height: height)) 21 | } 22 | 23 | static func resize(image: UIImage, height: CGFloat) -> UIImage { 24 | let width = (height / image.size.height) * image.size.width 25 | return resize(image: image, size: CGSize(width: width, height: height)) 26 | } 27 | 28 | static func resize(image: UIImage, size: CGSize) -> UIImage { 29 | // Check if scaling is needed 30 | guard 31 | abs((image.size.width * image.scale) - size.width) > 0 32 | || abs((image.size.height * image.scale) - size.height) > 0 33 | else { 34 | return image 35 | } 36 | 37 | if abs(image.size.width / image.size.height - size.width / size.height) < 1e-2 { 38 | // Scaled image has close to same aspect ratio, 39 | // updating image scale instead of resizing image. 40 | let scale = (image.scale * ((image.size.width * image.scale) / size.width)) 41 | return UIImage(cgImage: image.cgImage!, scale: scale, orientation: image.imageOrientation) 42 | } else { 43 | UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.main.scale) 44 | image.draw(in: CGRect(origin: .zero, size: size)) 45 | let newImage = UIGraphicsGetImageFromCurrentImageContext() 46 | UIGraphicsEndImageContext() 47 | return newImage! 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/LocationManager.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import CoreLocation 16 | import Foundation 17 | 18 | class LocationManager { 19 | static let shared = LocationManager() 20 | 21 | private let _locationManager = CLLocationManager() 22 | 23 | func requestAlwaysAuthorization() { 24 | _locationManager.requestAlwaysAuthorization() 25 | } 26 | 27 | func startUpdatingLocation() { 28 | _locationManager.startUpdatingLocation() 29 | } 30 | 31 | func stopUpdatingLocation() { 32 | _locationManager.stopUpdatingLocation() 33 | } 34 | 35 | func allowBackgroundLocationUpdates(allow: Bool) { 36 | _locationManager.allowsBackgroundLocationUpdates = allow 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/RegisteredImage.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import UIKit 16 | 17 | struct RegisteredImage { 18 | let imageId: String 19 | let image: UIImage 20 | let imagePixelRatio: Double 21 | let width: Double? 22 | let height: Double? 23 | 24 | func toImageDescriptorDto() -> ImageDescriptorDto { 25 | ImageDescriptorDto( 26 | registeredImageId: imageId, 27 | imagePixelRatio: imagePixelRatio, 28 | width: width, 29 | height: height 30 | ) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/Utilities.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import UIKit 16 | 17 | extension String { 18 | static var empty: String { "" } 19 | } 20 | 21 | extension Collection { 22 | var isNotEmpty: Bool { !isEmpty } 23 | } 24 | 25 | extension UIColor { 26 | convenience init(from rgb: Int64) { 27 | let blue = rgb & 0xFF 28 | let green = (rgb >> 8) & 0xFF 29 | let red = (rgb >> 16) & 0xFF 30 | let alpha = (rgb >> 24) & 0xFF 31 | 32 | self.init( 33 | red: CGFloat(red) / 255, 34 | green: CGFloat(green) / 255, 35 | blue: CGFloat(blue) / 255, 36 | alpha: CGFloat(alpha) / 255) 37 | } 38 | 39 | func toRgb() -> Int64? { 40 | var red: CGFloat = 0 41 | var green: CGFloat = 0 42 | var blue: CGFloat = 0 43 | var alpha: CGFloat = 0 44 | if getRed(&red, green: &green, blue: &blue, alpha: &alpha) { 45 | let redInt = Int(red * 255.0) 46 | let greenInt = Int(green * 255.0) 47 | let blueInt = Int(blue * 255.0) 48 | let alphaInt = Int(alpha * 255.0) 49 | 50 | let rgb = (alphaInt << 24) + (redInt << 16) + (greenInt << 8) + blueInt 51 | return Int64(rgb) 52 | } else { 53 | return nil 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/ViewSettledDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import UIKit 16 | 17 | protocol ViewSettledDelegate: AnyObject { 18 | func onViewSettled(_ view: UIView) 19 | } 20 | -------------------------------------------------------------------------------- /ios/google_navigation_flutter/Sources/google_navigation_flutter/ViewStateAwareGMSMapView.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | import GoogleNavigation 15 | 16 | class ViewStateAwareGMSMapView: GMSMapView { 17 | private var _isSettled: Bool = false 18 | private var _prevBounds: CGRect = .zero 19 | 20 | weak var viewSettledDelegate: ViewSettledDelegate? { 21 | didSet { 22 | // Call didSet immediately if isSettled is true 23 | if _isSettled, let delegate = viewSettledDelegate { 24 | delegate.onViewSettled(self) 25 | viewSettledDelegate = nil 26 | } 27 | } 28 | } 29 | 30 | func checkSettled() { 31 | if _isSettled { return } 32 | if superview == nil { return } 33 | if bounds.size.width != 0, bounds.size.height != 0 { 34 | _isSettled = true 35 | viewSettledDelegate?.onViewSettled(self) 36 | viewSettledDelegate = nil 37 | } 38 | } 39 | 40 | override public func layoutSubviews() { 41 | if !_isSettled, bounds != _prevBounds { 42 | _prevBounds = bounds 43 | checkSettled() 44 | } 45 | 46 | super.layoutSubviews() 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/google_navigation_flutter.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export 'src/google_maps_image_registry.dart'; 16 | export 'src/google_navigation_flutter.dart'; 17 | export 'src/google_navigation_flutter_android.dart'; 18 | export 'src/google_navigation_flutter_ios.dart'; 19 | export 'src/navigator/google_navigation_flutter_navigator.dart'; 20 | export 'src/types/types.dart'; 21 | export 'src/google_maps_navigation_view.dart'; 22 | export 'src/google_maps_map_view.dart'; 23 | export 'src/google_maps_map_view_controller.dart'; 24 | export 'src/google_maps_navigation_view_controller.dart'; 25 | export 'src/google_maps_auto_view_controller.dart'; 26 | -------------------------------------------------------------------------------- /lib/src/inspector/inspector_android.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import 'package:flutter/foundation.dart'; 16 | import 'inspector_platform.dart'; 17 | 18 | /// An Android of implementation of [GoogleNavigationInspectorPlatform]. 19 | /// @nodoc 20 | @visibleForTesting 21 | class GoogleNavigationInspectorAndroid 22 | extends GoogleNavigationInspectorPlatform { 23 | // Nothing currently here. 24 | } 25 | -------------------------------------------------------------------------------- /lib/src/inspector/inspector_ios.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import 'package:flutter/foundation.dart'; 16 | import 'inspector_platform.dart'; 17 | 18 | /// An iOS of implementation of [GoogleNavigationInspectorPlatform]. 19 | /// @nodoc 20 | @visibleForTesting 21 | class GoogleNavigationInspectorIOS extends GoogleNavigationInspectorPlatform { 22 | // Nothing currently here. 23 | } 24 | -------------------------------------------------------------------------------- /lib/src/inspector/inspector_platform.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 16 | 17 | import '../method_channel/method_channel.dart'; 18 | 19 | /// The interface that platform-specific implementations of 20 | /// `google_navigation_flutter` can extend to support state inspection in tests. 21 | /// 22 | /// Avoid `implements` of this interface. Using `implements` makes adding any 23 | /// new methods here a breaking change for end users of your platform! 24 | /// 25 | /// Do `extends GoogleNavigationInspectorPlatform` instead, so new methods 26 | /// added here are inherited in your code with the default implementation (that 27 | /// throws at runtime), rather than breaking your users at compile time. 28 | /// @nodoc 29 | abstract class GoogleNavigationInspectorPlatform extends PlatformInterface { 30 | /// Constructs a GoogleNavigationInspectorPlatform. 31 | GoogleNavigationInspectorPlatform() : super(token: _token); 32 | 33 | final NavigationInspector _inspector = NavigationInspector(); 34 | 35 | static final Object _token = Object(); 36 | 37 | static GoogleNavigationInspectorPlatform? _instance; 38 | 39 | /// The instance of [GoogleNavigationInspectorPlatform], if any. 40 | /// 41 | /// This is usually populated by calling 42 | /// [GoogleNavigationFlutterPlatform.enableDebugInspection]. 43 | static GoogleNavigationInspectorPlatform? get instance => _instance; 44 | 45 | /// Platform-specific plugins should set this with their own platform-specific 46 | /// class that extends [GoogleNavigationInspectorPlatform] in their 47 | /// implementation of [GoogleNavigationFlutterPlatform.enableDebugInspection]. 48 | static set instance(GoogleNavigationInspectorPlatform? instance) { 49 | if (instance != null) { 50 | PlatformInterface.verify(instance, _token); 51 | } 52 | _instance = instance; 53 | } 54 | 55 | /// Internal testing function to check guidance status. 56 | Future isViewAttachedToSession(int viewId) async { 57 | return _inspector.isViewAttachedToSession(viewId); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/camera.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../../google_navigation_flutter.dart'; 16 | import '../method_channel.dart'; 17 | 18 | /// [CameraPositionDto] convert extension. 19 | /// @nodoc 20 | extension ConvertCameraPositionDto on CameraPositionDto { 21 | /// Convert [CameraPositionDto] to [CameraPosition]. 22 | CameraPosition toCameraPosition() => CameraPosition( 23 | bearing: bearing, target: target.toLatLng(), tilt: tilt, zoom: zoom); 24 | } 25 | 26 | /// [CameraPosition] convert extension. 27 | /// @nodoc 28 | extension ConvertCameraPosition on CameraPosition { 29 | /// Convert [CameraPosition] to [CameraPositionDto]. 30 | CameraPositionDto toCameraPosition() => CameraPositionDto( 31 | bearing: bearing, target: target.toDto(), tilt: tilt, zoom: zoom); 32 | } 33 | 34 | /// [CameraPerspective] convert extension. 35 | /// @nodoc 36 | extension ConvertCameraPerspective on CameraPerspective { 37 | /// Convert [CameraPerspective] to [CameraPerspectiveDto]. 38 | CameraPerspectiveDto toDto() { 39 | switch (this) { 40 | case CameraPerspective.tilted: 41 | return CameraPerspectiveDto.tilted; 42 | case CameraPerspective.topDownHeadingUp: 43 | return CameraPerspectiveDto.topDownHeadingUp; 44 | case CameraPerspective.topDownNorthUp: 45 | return CameraPerspectiveDto.topDownNorthUp; 46 | } 47 | } 48 | } 49 | 50 | /// [CameraEventTypeDto] convert extension. 51 | /// @nodoc 52 | extension ConvertCameraEventTypeDto on CameraEventTypeDto { 53 | /// Convert [CameraEventTypeDto] to [CameraEventType]. 54 | CameraEventType toCameraEventType() { 55 | switch (this) { 56 | case CameraEventTypeDto.moveStartedByApi: 57 | return CameraEventType.moveStartedByApi; 58 | case CameraEventTypeDto.moveStartedByGesture: 59 | return CameraEventType.moveStartedByGesture; 60 | case CameraEventTypeDto.onCameraMove: 61 | return CameraEventType.onCameraMove; 62 | case CameraEventTypeDto.onCameraIdle: 63 | return CameraEventType.onCameraIdle; 64 | case CameraEventTypeDto.onCameraStartedFollowingLocation: 65 | return CameraEventType.onCameraStartedFollowingLocation; 66 | case CameraEventTypeDto.onCameraStoppedFollowingLocation: 67 | return CameraEventType.onCameraStoppedFollowingLocation; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/circle.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | import 'dart:ui'; 15 | 16 | import '../../../google_navigation_flutter.dart'; 17 | import '../../utils/color.dart'; 18 | import '../method_channel.dart'; 19 | 20 | /// [CircleDto] convert extension. 21 | /// @nodoc 22 | extension ConvertCircleDto on CircleDto { 23 | /// Convert [CircleDto] to [Circle]. 24 | Circle toCircle() { 25 | return Circle(circleId: circleId, options: options.toCircleOptions()); 26 | } 27 | } 28 | 29 | /// [Circle] convert extension. 30 | /// @nodoc 31 | extension ConvertCircle on Circle { 32 | /// Convert [Circle] to [CircleDto]. 33 | CircleDto toDto() { 34 | return CircleDto(circleId: circleId, options: options.toDto()); 35 | } 36 | } 37 | 38 | /// [CircleOptionsDto] convert extension. 39 | /// @nodoc 40 | extension ConvertCircleOptionsDto on CircleOptionsDto { 41 | /// Convert [CircleOptionsDto] to [CircleOptions]. 42 | CircleOptions toCircleOptions() { 43 | return CircleOptions( 44 | position: position.toLatLng(), 45 | radius: radius, 46 | clickable: clickable, 47 | fillColor: Color(fillColor), 48 | strokeColor: Color(strokeColor), 49 | strokeWidth: strokeWidth, 50 | strokePattern: strokePattern 51 | .map((PatternItemDto? e) => e?.toPatternItem()) 52 | .whereType() 53 | .toList(), 54 | visible: visible, 55 | zIndex: zIndex); 56 | } 57 | } 58 | 59 | /// [CircleOptions] convert extension. 60 | /// @nodoc 61 | extension ConvertCircleOptions on CircleOptions { 62 | /// Convert [CircleOptions] to [CircleOptionsDto]. 63 | CircleOptionsDto toDto() { 64 | return CircleOptionsDto( 65 | position: position.toDto(), 66 | radius: radius, 67 | strokePattern: 68 | strokePattern.map((PatternItem pi) => pi.toDto()).toList(), 69 | clickable: clickable, 70 | fillColor: colorToInt(fillColor)!, 71 | strokeColor: colorToInt(strokeColor)!, 72 | strokeWidth: strokeWidth, 73 | visible: visible, 74 | zIndex: zIndex); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/convert.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export 'camera.dart'; 16 | export 'circle.dart'; 17 | export 'destinations.dart'; 18 | export 'latlng.dart'; 19 | export 'latlng_bounds.dart'; 20 | export 'map_type.dart'; 21 | export 'marker.dart'; 22 | export 'navigation.dart'; 23 | export 'navigation_display_options.dart'; 24 | export 'navigation_routing_options.dart'; 25 | export 'navinfo.dart'; 26 | export 'pattern.dart'; 27 | export 'polygon.dart'; 28 | export 'polyline.dart'; 29 | export 'simulation.dart'; 30 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/destinations.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../types/types.dart'; 16 | import '../method_channel.dart'; 17 | import 'navigation_route_token_options.dart'; 18 | import 'navigation_waypoint.dart'; 19 | 20 | /// [Destinations] convert extension. 21 | /// @nodoc 22 | extension ConvertDestinations on Destinations { 23 | /// Converts [Destinations] to [DestinationsDto] 24 | DestinationsDto toDto() => DestinationsDto( 25 | waypoints: waypoints.map( 26 | (NavigationWaypoint e) { 27 | return e.toDto(); 28 | }, 29 | ).toList(), 30 | displayOptions: displayOptions.toDto(), 31 | routingOptions: routingOptions?.toDto(), 32 | routeTokenOptions: routeTokenOptions?.toDto()); 33 | } 34 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/latlng.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../types/types.dart'; 16 | import '../method_channel.dart'; 17 | 18 | /// [LatLng] convert extension. 19 | /// @nodoc 20 | extension ConvertLatLng on LatLng { 21 | /// Converts [LatLng] to [LatLngDto] 22 | LatLngDto toDto() { 23 | return LatLngDto(latitude: latitude, longitude: longitude); 24 | } 25 | } 26 | 27 | /// [LatLngDto] convert extension. 28 | /// @nodoc 29 | extension ConvertLatLngDto on LatLngDto { 30 | /// Converts [LatLngDto] to [LatLng] 31 | LatLng toLatLng() { 32 | return LatLng(latitude: latitude, longitude: longitude); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/latlng_bounds.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../types/types.dart'; 16 | import '../method_channel.dart'; 17 | 18 | /// [LatLngBounds] convert extension. 19 | /// @nodoc 20 | extension ConvertLatLngBounds on LatLngBounds { 21 | /// Convert [LatLngBounds] to [LatLngBoundsDto]. 22 | LatLngBoundsDto toDto() => LatLngBoundsDto( 23 | northeast: northeast.toDto(), 24 | southwest: southwest.toDto(), 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/map_type.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../types/types.dart'; 16 | import '../method_channel.dart'; 17 | 18 | /// [MapType] convert extension. 19 | /// @nodoc 20 | extension ConvertMapType on MapType { 21 | /// Converts [MapType] to [MapTypeDto] 22 | MapTypeDto toDto() { 23 | switch (this) { 24 | case MapType.none: 25 | return MapTypeDto.none; 26 | case MapType.hybrid: 27 | return MapTypeDto.hybrid; 28 | case MapType.normal: 29 | return MapTypeDto.normal; 30 | case MapType.satellite: 31 | return MapTypeDto.satellite; 32 | case MapType.terrain: 33 | return MapTypeDto.terrain; 34 | } 35 | } 36 | } 37 | 38 | /// [MapTypeDto] convert extension. 39 | /// @nodoc 40 | extension ConvertMapTypeDto on MapTypeDto { 41 | /// Converts [MapTypeDto] to [MapType] 42 | MapType toMapType() { 43 | switch (this) { 44 | case MapTypeDto.none: 45 | return MapType.none; 46 | case MapTypeDto.hybrid: 47 | return MapType.hybrid; 48 | case MapTypeDto.normal: 49 | return MapType.normal; 50 | case MapTypeDto.satellite: 51 | return MapType.satellite; 52 | case MapTypeDto.terrain: 53 | return MapType.terrain; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/navigation_display_options.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../types/types.dart'; 16 | import '../method_channel.dart'; 17 | 18 | /// [NavigationDisplayOptions] convert extension. 19 | /// @nodoc 20 | extension ConvertNavigationDisplayOptions on NavigationDisplayOptions { 21 | /// Converts [NavigationWaypoint] to [NavigationDisplayOptionsDto] 22 | NavigationDisplayOptionsDto toDto() => NavigationDisplayOptionsDto( 23 | showDestinationMarkers: showDestinationMarkers, 24 | showStopSigns: showStopSigns, 25 | showTrafficLights: showTrafficLights, 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/navigation_route_token_options.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../types/types.dart'; 16 | import '../method_channel.dart'; 17 | 18 | /// [NavigationDisplayOptions] convert extension. 19 | /// @nodoc 20 | extension ConvertRouteTokenOptions on RouteTokenOptions { 21 | /// Converts [RouteTokenOptions] to [RouteTokenOptionsDto] 22 | RouteTokenOptionsDto toDto() => RouteTokenOptionsDto( 23 | routeToken: routeToken, 24 | travelMode: travelMode?.toDto(), 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/navigation_waypoint.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../types/types.dart'; 16 | import '../method_channel.dart'; 17 | 18 | /// [NavigationWaypointDto] convert extension. 19 | /// @nodoc 20 | extension ConvertNavigationWaypointDto on NavigationWaypointDto { 21 | /// Converts [NavigationWaypointDto] to [NavigationWaypoint] 22 | NavigationWaypoint toNavigationWaypoint() => NavigationWaypoint( 23 | title: title, 24 | target: target?.toLatLng(), 25 | placeID: placeID, 26 | preferSameSideOfRoad: preferSameSideOfRoad, 27 | preferredSegmentHeading: preferredSegmentHeading, 28 | ); 29 | } 30 | 31 | /// [NavigationWaypoint] convert extension. 32 | /// @nodoc 33 | extension ConvertNavigationWaypoint on NavigationWaypoint { 34 | /// Converts [NavigationWaypoint] to [NavigationWaypointDto] 35 | NavigationWaypointDto toDto() => NavigationWaypointDto( 36 | title: title, 37 | target: target?.toDto(), 38 | placeID: placeID, 39 | preferSameSideOfRoad: preferSameSideOfRoad, 40 | preferredSegmentHeading: preferredSegmentHeading, 41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/pattern.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../../google_navigation_flutter.dart'; 16 | import '../method_channel.dart'; 17 | 18 | /// [PatternItemDto] convert extension. 19 | /// @nodoc 20 | extension ConvertPatternItemDto on PatternItemDto { 21 | /// Convert [PatternItemDto] to [PatternItem]. 22 | PatternItem toPatternItem() { 23 | switch (type) { 24 | case PatternTypeDto.dash: 25 | return DashPattern(length: length!); 26 | case PatternTypeDto.dot: 27 | return const DotPattern(); 28 | case PatternTypeDto.gap: 29 | return GapPattern(length: length!); 30 | } 31 | } 32 | } 33 | 34 | /// [PatternItem] convert extension. 35 | /// @nodoc 36 | extension ConvertPatternItem on PatternItem { 37 | /// Convert [PatternItem] to [PatternItemDto]. 38 | PatternItemDto toDto() { 39 | switch (type) { 40 | case PatternType.dash: 41 | return PatternItemDto( 42 | type: PatternTypeDto.dash, 43 | length: (this as DashPattern).length, 44 | ); 45 | case PatternType.dot: 46 | return PatternItemDto( 47 | type: PatternTypeDto.dot, 48 | ); 49 | case PatternType.gap: 50 | return PatternItemDto( 51 | type: PatternTypeDto.gap, 52 | length: (this as GapPattern).length, 53 | ); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/src/method_channel/convert/simulation.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import '../../../google_navigation_flutter.dart'; 16 | import '../method_channel.dart'; 17 | 18 | /// Converts navigation options to the Pigeon DTO format. 19 | /// @nodoc 20 | SimulationOptionsDto simulationOptionsToDto(SimulationOptions options) { 21 | return SimulationOptionsDto(speedMultiplier: options.speedMultiplier); 22 | } 23 | -------------------------------------------------------------------------------- /lib/src/method_channel/image_api.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import 'package:flutter/services.dart'; 16 | 17 | import '../../google_navigation_flutter.dart'; 18 | import 'method_channel.dart'; 19 | 20 | /// @nodoc 21 | /// CommonImageRegistryAPI handles image registry API 22 | /// actions that are common to both iOS and Android. 23 | class ImageRegistryAPIImpl { 24 | final ImageRegistryApi _imageApi = ImageRegistryApi(); 25 | 26 | /// Keep track of image count, used to generate image ID's. 27 | int _imageCounter = 0; 28 | String _createImageId() { 29 | final String imageId = 'Image_$_imageCounter'; 30 | _imageCounter += 1; 31 | return imageId; 32 | } 33 | 34 | /// Register bitmap to image registry. 35 | Future registerBitmapImage( 36 | {required Uint8List bitmap, 37 | required double imagePixelRatio, 38 | double? width, 39 | double? height}) async { 40 | final String newImageId = _createImageId(); 41 | try { 42 | final ImageDescriptorDto addedImage = await _imageApi.registerBitmapImage( 43 | newImageId, bitmap, imagePixelRatio, width, height); 44 | return addedImage.toImageDescriptor(); 45 | } on PlatformException catch (error) { 46 | if (error.code == 'imageDecodingFailed') { 47 | throw const ImageDecodingFailedException(); 48 | } else { 49 | rethrow; 50 | } 51 | } 52 | } 53 | 54 | /// Delete bitmap from image registry. 55 | Future unregisterImage({required ImageDescriptor imageDescriptor}) { 56 | return _imageApi.unregisterImage(imageDescriptor.toDto()); 57 | } 58 | 59 | /// Get all registered bitmaps from image registry. 60 | Future> getRegisteredImages() async { 61 | final List registeredImages = 62 | await _imageApi.getRegisteredImages(); 63 | return registeredImages 64 | .whereType() 65 | .map((ImageDescriptorDto e) => e.toImageDescriptor()) 66 | .toList(); 67 | } 68 | 69 | /// Remove all registered bitmaps from image registry. 70 | Future clearRegisteredImages() { 71 | return _imageApi.clearRegisteredImages(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/src/method_channel/method_channel.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export 'auto_view_api.dart'; 16 | export 'image_api.dart'; 17 | export 'session_api.dart'; 18 | export 'map_view_api.dart'; 19 | export 'convert/convert.dart'; 20 | export 'messages.g.dart'; 21 | -------------------------------------------------------------------------------- /lib/src/types/images.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import 'package:flutter/foundation.dart'; 16 | import 'package:flutter/material.dart'; 17 | 18 | /// Defines an image. For marker this class can be used to set the 19 | /// image of the marker icon. 20 | /// {@category Image Registry} 21 | @immutable 22 | class ImageDescriptor { 23 | /// Construct [ImageDescriptor]. 24 | const ImageDescriptor( 25 | {this.registeredImageId, this.imagePixelRatio, this.width, this.height}); 26 | 27 | /// If this class represents an image from image registry, [registeredImageId] is not null. 28 | final String? registeredImageId; 29 | 30 | /// If image is bigger than it's intended display size, scale it down by this ratio. 31 | final double? imagePixelRatio; 32 | 33 | /// Image width in logical pixels. 34 | final double? width; 35 | 36 | /// Image height in logical pixels. 37 | final double? height; 38 | 39 | /// Display default image on a marker or polyline. 40 | static const ImageDescriptor defaultImage = ImageDescriptor(); 41 | 42 | @override 43 | bool operator ==(Object other) { 44 | if (identical(this, other)) { 45 | return true; 46 | } 47 | if (other.runtimeType != runtimeType) { 48 | return false; 49 | } 50 | return other is ImageDescriptor && 51 | registeredImageId == other.registeredImageId && 52 | imagePixelRatio == other.imagePixelRatio && 53 | width == other.width && 54 | height == other.height; 55 | } 56 | 57 | @override 58 | int get hashCode => Object.hash(registeredImageId.hashCode, 59 | imagePixelRatio.hashCode, width.hashCode, height.hashCode); 60 | } 61 | -------------------------------------------------------------------------------- /lib/src/types/lat_lng.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import 'package:flutter/foundation.dart'; 16 | 17 | /// LatLng coordinate object. 18 | /// {@category Navigation} 19 | /// {@category Navigation View} 20 | /// {@category Map View} 21 | @immutable 22 | class LatLng { 23 | /// Initializes a [LatLng] with the provided latitude and longitude values. 24 | const LatLng({ 25 | required this.latitude, 26 | required this.longitude, 27 | }) : assert(latitude >= -90.0 && latitude <= 90.0, 28 | 'Latitude must be between -90 and 90 degrees.'), 29 | assert(longitude >= -180.0 && longitude <= 180.0, 30 | 'Longitude must be between -180 and 180 degrees.'); 31 | 32 | /// The latitude of this point in degrees, where negative values indicate south of the equator. 33 | final double latitude; 34 | 35 | /// The longitude of this point in degrees, where negative values indicate west of the prime meridian. 36 | final double longitude; 37 | 38 | /// Returns a new [LatLng] instance offset by the given [LatLng]. 39 | /// Asserts that the operation does not cross the poles. 40 | LatLng offset(LatLng offset) { 41 | final double newLatitude = latitude + offset.latitude; 42 | assert(newLatitude >= -90.0 && newLatitude <= 90.0, 43 | 'Latitude after applying offset must be between -90 and 90 degrees.'); 44 | 45 | // Handle longitude wrap-around (across the 180th meridian) 46 | double newLongitude = longitude + offset.longitude; 47 | newLongitude = (newLongitude + 180) % 360 - 180; 48 | 49 | return LatLng(latitude: newLatitude, longitude: newLongitude); 50 | } 51 | 52 | /// Returns a new [LatLng] instance with the latitude and longitude negated. 53 | LatLng operator -() => LatLng(latitude: -latitude, longitude: -longitude); 54 | 55 | @override 56 | bool operator ==(Object other) { 57 | if (identical(this, other)) { 58 | return true; 59 | } 60 | if (other.runtimeType != runtimeType) { 61 | return false; 62 | } 63 | return other is LatLng && 64 | latitude == other.latitude && 65 | longitude == other.longitude; 66 | } 67 | 68 | @override 69 | int get hashCode => Object.hash(latitude.hashCode, longitude.hashCode); 70 | } 71 | -------------------------------------------------------------------------------- /lib/src/types/navigation_initialization_params.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /// Determines how application should behave when a application task is removed. 16 | /// 17 | /// Android only. 18 | /// {@category Navigation} 19 | enum TaskRemovedBehavior { 20 | /// The default state, indicating that navigation guidance, 21 | /// location updates, and notification should persist after user removes the application task. 22 | continueService, 23 | 24 | /// Indicates that navigation guidance, location updates, and notification should shut down immediately when the user removes the application task. 25 | quitService, 26 | } 27 | -------------------------------------------------------------------------------- /lib/src/types/types.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | export 'circles.dart'; 16 | export 'images.dart'; 17 | export 'lat_lng.dart'; 18 | export 'lat_lng_bounds.dart'; 19 | export 'markers.dart'; 20 | export 'navigation_destinations.dart'; 21 | export 'navigation_initialization_params.dart'; 22 | export 'navigation_view_types.dart'; 23 | export 'navinfo.dart'; 24 | export 'polygons.dart'; 25 | export 'polylines.dart'; 26 | export 'simulation.dart'; 27 | export 'stroke_patterns.dart'; 28 | export 'view_initialization_options.dart'; 29 | -------------------------------------------------------------------------------- /lib/src/utils/color.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | import 'dart:ui'; 15 | 16 | int? colorToInt(Color? color) { 17 | if (color == null) { 18 | return null; 19 | } 20 | 21 | int floatToInt8(double x) => (x * 255.0).round() & 0xff; 22 | 23 | return (floatToInt8(color.a) << 24) | 24 | (floatToInt8(color.r) << 16) | 25 | (floatToInt8(color.g) << 8) | 26 | (floatToInt8(color.b)); 27 | } 28 | -------------------------------------------------------------------------------- /pigeons/copyright.txt: -------------------------------------------------------------------------------- 1 | Copyright 2023 Google LLC 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | https://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: google_navigation_flutter 16 | description: A plugin for adding Google Navigation widget to Flutter apps targeting Android and iOS 17 | repository: https://github.com/googlemaps/flutter-navigation-sdk 18 | issue_tracker: https://github.com/googlemaps/flutter-navigation-sdk/issues 19 | version: 0.6.1 20 | 21 | environment: 22 | sdk: ^3.6.0 23 | flutter: ">=3.27.0" 24 | 25 | dependencies: 26 | collection: ^1.17.2 27 | flutter: 28 | sdk: flutter 29 | flutter_plugin_android_lifecycle: ^2.0.16 30 | plugin_platform_interface: ^2.1.5 31 | stream_transform: ^2.1.0 32 | 33 | dev_dependencies: 34 | build_runner: ^2.4.6 35 | flutter_lints: ^4.0.0 36 | flutter_test: 37 | sdk: flutter 38 | melos: ^6.0.0 39 | mockito: 5.4.4 40 | pigeon: 15.0.0 41 | 42 | flutter: 43 | plugin: 44 | platforms: 45 | android: 46 | package: com.google.maps.flutter.navigation 47 | pluginClass: GoogleMapsNavigationPlugin 48 | dartPluginClass: GoogleMapsNavigationAndroid 49 | ios: 50 | pluginClass: GoogleMapsNavigationPlugin 51 | dartPluginClass: GoogleMapsNavigationIOS 52 | -------------------------------------------------------------------------------- /release-please-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", 3 | "release-type": "dart", 4 | "include-component-in-tag": false, 5 | "include-v-in-tag": false, 6 | "bump-minor-pre-major": true, 7 | "bump-patch-for-minor-pre-major": true, 8 | "packages": { 9 | ".": { 10 | "package-name": "google_navigation_flutter", 11 | "changelog-path": "CHANGELOG.md" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tool/test-ios.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2024 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | set -e 16 | 17 | DEVICE_NAME=${TEST_DEVICE:-'iPhone 16 Pro'} # Default to 'iPhone 16 Pro' if no argument is provided 18 | OS_VERSION=${TEST_OS:-'18.1'} # Default to 'iPhone 16 Pro' if no argument is provided 19 | 20 | # Navigate to the ios directory and run xcodebuild with the provided device name 21 | cd ios && xcodebuild test \ 22 | -workspace Runner.xcworkspace \ 23 | -scheme Runner \ 24 | -only-testing RunnerTests \ 25 | -configuration Debug \ 26 | -sdk iphoneos -destination "platform=iOS Simulator,name=$DEVICE_NAME,OS=$OS_VERSION" \ 27 | -derivedDataPath ../build/ios_unit 28 | --------------------------------------------------------------------------------