UNPKG

expo-osm-sdk

Version:

OpenStreetMap component for React Native with Expo

68 lines 2.23 kB
import { Coordinate, Route, OSMViewRef } from '../types'; import { OSRMRouteOptions } from '../utils/osrm'; /** * OSRM Routing Hook State */ export interface OSRMRoutingState { isCalculating: boolean; error: string | null; currentRoute: Route | null; routeDisplayed: boolean; } /** * OSRM Routing Hook Return Type */ export interface UseOSRMRoutingReturn { state: OSRMRoutingState; calculateRoute: (from: Coordinate, to: Coordinate, options?: OSRMRouteOptions) => Promise<Route | null>; calculateAndDisplayRoute: (from: Coordinate, to: Coordinate, mapRef: React.RefObject<OSMViewRef>, options?: OSRMRouteOptions & { routeStyle?: RouteDisplayOptions; }) => Promise<Route | null>; displayRoute: (route: Route, mapRef: React.RefObject<OSMViewRef>, options?: RouteDisplayOptions) => Promise<void>; clearRoute: (mapRef: React.RefObject<OSMViewRef>) => Promise<void>; fitRouteInView: (route: Route, mapRef: React.RefObject<OSMViewRef>, padding?: number) => Promise<void>; formatRouteDuration: (route: Route) => string; formatRouteDistance: (route: Route) => string; getRouteEstimate: (route: Route) => { duration: string; distance: string; estimatedTime: string; }; reset: () => void; } /** * Route Display Options */ export interface RouteDisplayOptions { color?: string; width?: number; opacity?: number; } /** * OSRM Routing Hook * * Provides comprehensive routing functionality with state management. * Handles route calculation via OSRM API, route display on native maps, * and error handling. * * @example * ```tsx * const routing = useOSRMRouting(); * const mapRef = useRef<OSMViewRef>(null); * * const handleCalculateRoute = async () => { * const route = await routing.calculateAndDisplayRoute( * { latitude: 40.7128, longitude: -74.0060 }, // NYC * { latitude: 34.0522, longitude: -118.2437 }, // LA * mapRef, * { profile: 'driving' } * ); * * if (route) { * console.log('Route calculated:', routing.formatRouteDistance(route)); * } * }; * ``` */ export declare const useOSRMRouting: () => UseOSRMRoutingReturn; //# sourceMappingURL=useOSRMRouting.d.ts.map