Hook to calculate a route between two points on the map. The route automatically recalculates when the origin, destination, or options change.
The result from the useMap hook
Route parameters including origin, destination, and optional configuration
A Route object containing the distance and route ID, or null if the route cannot be calculated
const route = useRoute(mapLoadResult, { origin: { latitude: 52.8952, longitude: -1.8431 }, destination: { latitude: 52.8982, longitude: -1.8463 }});if (route) { console.log(`Distance: ${route.distance} meters`);} Copy
const route = useRoute(mapLoadResult, { origin: { latitude: 52.8952, longitude: -1.8431 }, destination: { latitude: 52.8982, longitude: -1.8463 }});if (route) { console.log(`Distance: ${route.distance} meters`);}
Hook to calculate a route between two points on the map. The route automatically recalculates when the origin, destination, or options change.