Overview
MapViewRoute is the main component of the react-native-maps-routes library. It renders a polyline route on a react-native-maps MapView using the Google Routes API to compute the optimal path between two or more locations.
The component automatically fetches route data from Google’s Routes API and renders it as a polyline overlay on your map.
Import
Props
Required Props
Starting point of the route. Must be a
react-native-maps LatLng object with latitude and longitude properties.Ending point of the route. Must be a
react-native-maps LatLng object with latitude and longitude properties.Your Google Maps API key with the Routes API enabled.
Optional Props
Array of intermediate points the route should pass through.
Travel mode for route calculation. One of:
"DRIVE", "BICYCLE", "TWO_WHEELER", or "WALK".Color of the route line in hex format.
Width of the route line in pixels.
How line segments are joined. One of:
"round", "bevel", or "miter".How line ends are drawn. One of:
"round", "butt", or "square".Options to modify route calculation such as avoiding tolls, highways, or ferries. See the Types page for details.
Override or add any field to the request body sent to Google Routes API. Applied after built-in fields. See Google Routes API documentation.
Enable calculation and callback of estimated travel time. Must be
true for onEstimatedTime callback to fire.Enable calculation and callback of route distance. Must be
true for onDistance callback to fire.Array of leg fields to request from the API. Required for
onLegs callback. See Types for available fields.Array of leg step fields to request from the API. Enables step-by-step navigation data. See Types for available fields.
Usage Example
See Also
- Props Reference - Complete props documentation
- Callbacks Reference - All callback props and their parameters
- Types Reference - TypeScript type definitions