react-native-maps-routes from other libraries or upgrade between major versions.
Migrating from react-native-maps-directions
If you’re currently usingreact-native-maps-directions, this library provides a modern alternative using the Google Maps Routes API instead of the Directions API.
Why Migrate?
The Google Maps Routes API (used by this library) offers several advantages over the Directions API:- Better route quality: More accurate and up-to-date routing
- Additional travel modes: Support for
TWO_WHEELERmode - Enhanced route modifiers: More granular control over route preferences
- Improved leg and step data: Better navigation instructions
- Modern API design: Built with newer Google Maps platform features
The Directions API is still supported by Google, but the Routes API is their newer, recommended solution for routing.
Key Differences
API Requirements
react-native-maps-directions:- Uses Google Maps Directions API
- Requires Directions API to be enabled
- Uses Google Maps Routes API
- Requires Routes API to be enabled (different API in Google Cloud Console)
Component Name
Prop Changes
Detailed Prop Mapping
| Old Prop (Directions) | New Prop (Routes) | Notes |
|---|---|---|
apikey | apiKey | Capital ‘K’ in Routes |
mode="DRIVING" | mode="DRIVE" | Different enum values |
mode="BICYCLING" | mode="BICYCLE" | Different enum values |
mode="WALKING" | mode="WALK" | Different enum values |
mode="TRANSIT" | Not supported | Use WALK or DRIVE instead |
| N/A | mode="TWO_WHEELER" | New mode only in Routes API |
optimizeWaypoints | Not available | Manual optimization needed |
splitWaypoints | Not available | Handle waypoint batching manually |
precision | Not needed | Routes API handles precision automatically |
timePrecision | Not needed | Use requestBodyOverrides for routing preferences |
region | Use requestBodyOverrides | { regionCode: 'us' } |
language | Use requestBodyOverrides | { languageCode: 'en' } |
avoid | routeModifiers | New typed object: { avoidTolls, avoidHighways, avoidFerries, avoidIndoor } |
onStart | Not available | Remove this callback |
onReady(result) | Multiple callbacks | Use onReady, onEstimatedTime, onDistance, onLegs separately |
resetOnChange | Not needed | Component resets automatically |
Migration Checklist
Enable the Routes API
Go to Google Cloud Console and enable the “Routes API” for your project.
Update component usage
- Change
apikeytoapiKey - Update mode values:
DRIVING→DRIVE,BICYCLING→BICYCLE,WALKING→WALK - Replace
avoidarrays withrouteModifiersobject - Split
onReadycallback into separateonEstimatedTime,onDistance, andonLegshandlers - Move
languageandregiontorequestBodyOverrides
Handle removed features
- Remove
optimizeWaypoints(implement your own optimization if needed) - Remove
splitWaypoints(handle waypoint batching manually) - Remove
onStartcallback - Remove
resetOnChangeprop - Remove
precisionandtimePrecisionprops
Handling Distance and Duration
The callbacks work differently:Upgrading Between Major Versions
Version 1.4.0 - Legs Support
Added in 1.4.0:legFieldsprop for requesting leg-level datalegStepFieldsprop for turn-by-turn navigation dataonLegscallback for receiving route leg information
Version 1.5.0 - Route Modifiers
Added in 1.5.0:routeModifiersprop for avoiding tolls, highways, ferries, or indoor routesrequestBodyOverridesprop for advanced customization
Version 1.3.0 - Waypoints Support
Added in 1.3.0:waypointsprop for intermediate stops (up to 25)
Version 1.2.0 - Distance Support
Added in 1.2.0:enableDistanceproponDistancecallback
Version 1.1.0 - Estimated Time
Added in 1.1.0:enableEstimatedTimeproponEstimatedTimecallback
Version 1.0.0 - Initial Release
First stable release with core functionality:- Basic routing between two points
- Travel mode support (DRIVE, WALK, BICYCLE, TWO_WHEELER)
- Customizable stroke styling
- Error handling
Getting Help
If you run into issues during migration:- Check the Examples for working code
- Review the API Reference for all available props
- See Troubleshooting for common problems
- Open an issue on GitHub