@maplayr/react-native
    Preparing search index...

    Function useRoute

    • Hook to calculate a route between two points on the map. The route automatically recalculates when the origin, destination, or options change.

      Parameters

      • mapLoadResult: MapLoadResult

        The result from the useMap hook

      • params: UseRouteParams

        Route parameters including origin, destination, and optional configuration

      Returns Route | null

      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`);
      }