@geoapify/route-directions
Version:
Route Directions component for Routing API - choose waypoints, select route options, calculate the route
86 lines (85 loc) • 3.39 kB
TypeScript
import { GeocoderAutocomplete } from "@geoapify/geocoder-autocomplete";
import type { GeocoderAutocompleteOptions, SupportedLanguage } from "@geoapify/geocoder-autocomplete";
export declare class RouteDirections {
private container;
private apiKey;
private MIN_ADDRESS_LENGTH;
private callbacksRouteCalculated;
private callbacksOptionsChanged;
private callbacksModeChanged;
private callbacksWaypointsChanged;
private routingUrl;
private geocodingAddress;
private reverseGeocodingAddress;
private allowedModes;
private dragElement;
private labels;
private geocoderOptions;
private options;
private currentTimeout;
private currentPromiseReject;
private previousRoutingAPICallURL;
constructor(container: HTMLElement, apiKey: string, options?: RouteDirectionsOptions, geocoderOptions?: GeocoderAutocompleteOptions);
calculate(): Promise<any>;
on(operation: 'modeChanged' | 'optionChanged' | 'waypointChanged' | 'routeCalculated', callback: WaypointChangeCallbackType | ModeChangeCallbackType | OptionChangeCallbackType | RouteCalculatedCallbackType): void;
off(operation: 'modeChanged' | 'optionChanged' | 'waypointChanged' | 'routeCalculated', callback: any): void;
addLocation(lat: number, lon: number, address?: string): void;
getOptions(): RouteDirectionsOptions;
private sendAutoRequest;
private inProgress;
private onWaypointsChanged;
private onOptionsChanged;
private onModeChanged;
private onRouteCalculated;
private checkAndfillWaypoints;
private updateWaypointControls;
private updateModeButtons;
private generateControls;
private generateOptions;
private generateWaypoint;
showMessage(error: any, isError?: boolean): void;
private handleDragStart;
private handleDragEnd;
private handleDragOver;
private getAllSiblings;
private handleDragEnter;
private handleDragLeave;
private handleDrop;
private addDradAndDropFunctionality;
private getElementIndex;
private moveWaypoints;
private removeWaypoint;
private swapWaypoints;
private addWaypoint;
private addIcon;
}
export interface RouteDirectionsOptions {
mode?: TravelMode;
avoidTolls?: boolean;
avoidFerries?: boolean;
avoidHighways?: boolean;
elevation?: boolean;
units?: "metric" | "imperial";
waypoints?: Waypoint[];
lang?: SupportedLanguage;
noStopover?: boolean;
supportedModes?: TravelMode[];
supportedOptions?: RoutingOption[];
calculateRouteTrigger?: 'auto' | 'buttonClick' | 'functionCall';
labels?: {
[key: string]: string;
};
debounceDelay?: number;
}
export type RoutingOption = 'tolls' | 'ferries' | 'highways' | 'units';
export type TravelMode = 'walk' | 'hike' | 'scooter' | 'motorcycle' | 'drive' | 'light_truck' | 'medium_truck' | 'truck' | 'bicycle' | 'mountain_bike' | 'road_bike' | 'bus';
export interface Waypoint {
address?: string;
lon?: number;
lat?: number;
geocoder?: GeocoderAutocomplete;
}
export type WaypointChangeCallbackType = (waypoint: Waypoint, reason: 'added' | 'removed' | 'changed' | 'moved') => void;
export type ModeChangeCallbackType = (mode: TravelMode) => void;
export type OptionChangeCallbackType = (option: RoutingOption) => void;
export type RouteCalculatedCallbackType = (geojson: any) => void;