Skip to content

Conversation

david-pivonka
Copy link

Summary

Implements integration with Google Routes API by adding setRouteToken method to NavigationController. This addresses issue #398 by allowing developers to use pre-calculated routes from the Routes API in the Navigation SDK.

Changes Made

  • TypeScript Interface: Added setRouteToken method to NavigationController interface
  • Android Implementation: Added native setRouteToken method using setDestinationsWithRouteToken
  • iOS Implementation: Added native setRouteToken method using setDestinationsWithRouteToken
  • React Native Bridge: Integrated TypeScript and native implementations
  • Documentation: Added usage examples and API documentation to README
  • Example App: Added demonstration button in sample app navigation controls

API Addition

setRouteToken(
  routeToken: string,
  displayOptions?: DisplayOptions
): Promise<void>;

Usage Example

try {
  // First, obtain a route token from the Google Routes API
  const routeToken = "your_route_token_from_routes_api";
  
  const displayOptions = {
    showDestinationMarkers: true,
    showStopSigns: true,
    showTrafficLights: true,
  };

  await navigationController.setRouteToken(routeToken, displayOptions);
  await navigationController.startGuidance();
} catch (error) {
  console.error('Error starting navigation with route token', error);
}

Test plan

  • TypeScript compilation passes
  • Linting passes
  • Build succeeds for all targets (commonjs, module, typescript)
  • Cross-platform implementation (Android + iOS)
  • Added example usage in sample app
  • Integration tests (to be added if requested)
  • Manual testing with actual route tokens from Routes API

Notes

The implementation follows the same patterns as existing setDestinations methods and integrates seamlessly with the current Navigation SDK architecture. Route tokens must be generated using the Google Routes API as documented.

Fixes #398

Implements integration with Google Routes API by adding setRouteToken method
to NavigationController. This addresses issue googlemaps#398 by allowing developers to
use pre-calculated routes from the Routes API in the Navigation SDK.

Changes:
- Add setRouteToken method to NavigationController interface
- Implement Android native support using setDestinationsWithRouteToken
- Implement iOS native support using setDestinationsWithRouteToken
- Add TypeScript types and React Native bridge integration
- Add documentation and example usage in README
- Add example button in sample app navigation controls

The implementation follows the same patterns as existing setDestinations
methods and provides cross-platform support for route token functionality.

Fixes googlemaps#398
Copy link

google-cla bot commented Aug 29, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request to support custom routes (integration with Routes API)
1 participant