DirectionsService
A service for calculating directions between locations.
Can be accessed by nextbillion.maps.DirectionsService
if you load SDK by CDN url.
Methods
Method | |
---|---|
route | route(opt: DirectionsRequest) Parameters
Return Value: Promise<null|DirectionsResult> Request directions between an origin and a destination. |
Interface DirectionsRequest
A directions query to be sent to the DirectionsSerivce
Properties
Name | |
---|---|
altCount Optional | Type: number Sets the number of alternative routes to return. Default: 3. |
alternatives Optional | Type: boolean If enabled, the API will return alternative routes. You can set the number of routes in the altcount property. |
apiKey Optional | Type: string api key for the request |
approaches Optional | Type: Array<ApproachType> A list indicating the side of the road from which to approach waypoints in a requested route. If provided, the number of approaches must be one more than the number of waypoints. |
avoid Optional | Type: Array<AvoidType> Setting this will ensure the route avoids ferry, tolls or highways. |
departureTime Optional | Type: number This parameter sets the departure time in Unix epoch time seconds format. Unit: seconds. PS: This parameter is only supported in Premium plan. |
destination | Type: LngLatLike The ending point of a route. |
geometry Optional | Type: GeometryType Sets the output format of the route geometry in the response. Default: GeometryType.POLYLINE6. |
mode Optional | Type: TravelMode | string A parameter which which sets the transportation mode for the route. PS: Only the 4w/car profile is enabled by default. The other customised routing profiles are only supported in Premium plan. |
option Optional | Type: string Use this option to switch to 6w or truck specific routing. Using this option enables specific settings available only for truck based routing. Accepts flexible . |
origin | Type: LngLatLike The starting point of a route. |
overview Optional | Type: OverviewType Output verbosity of overview (whole trip) geometry. Default: full. |
session Optional | Type: string Unique session ID. If set, the response will reuse cached trip characteristics. PS: This parameter is only supported in Premium plan. |
steps Optional | Type: boolean The steps flag determines whether to return the individual maneuver instructions that comprise the route in the response. |
waypoints Optional | Type: Array<LngLatLike> Coordinates along the route between the Origin and the Destination. |
Interface DirectionsResult
The directions response retrieved from the directions server.
Properties
Name | |
---|---|
country_code Optional | Type: string |
msg Optional | Type: string error message if status is not 200. |
routes Optional | Type: Array<DirectionsResponseRoute> routes calculated. |
status | Type: NBRequestStatus | string A string indicating the state of the response. This is a separate code than the HTTP status code. On normal valid responses, the value will be Ok. |
Interface DirectionsResponseRoute
Properties
Name | |
---|---|
distance | Type: number |
distance_full Optional | Type: number |
duration | Type: number |
end_location Optional | Type: { latitude: number,longitude: number } |
geojson Optional | Type: { coordinates: Array<Array<number>> } |
geometry Optional | Type: string encoded geometry value for step in polyline or polyline6. |
legs | Type: Array<DirectionsResponseLeg> |
predicted_duration Optional | Type: number |
raw_duration Optional | Type: number |
special_objects Optional | Type: any |
start_location Optional | Type: { latitude: number,longitude: number } |
Interface DirectionsResponseLeg
Properties
Name | |
---|---|
distance | Type: { value: number } |
duration | Type: { value: number } |
end_location Optional | Type: { latitude: number,longitude: number } |
raw_duration Optional | Type: { value: number } |
start_location Optional | Type: { latitude: number,longitude: number } |
steps | Type: Array<DirectionsResponseLegStep> |
Interface DirectionsResponseLegStep
Properties
Name | |
---|---|
distance | Type: { value: number } |
duration | Type: { value: number } |
end_location | Type: { latitude: number,longitude: number } |
geojson Optional | Type: { coordinates: Array<Array<number>> } |
geometry Optional | Type: string |
intersections Optional | Type: Array<StepIntersections> |
maneuver Optional | Type: StepManeuver |
name Optional | Type: string |
reference Optional | Type: string |
start_location | Type: { latitude: number,longitude: number } |
Interface StepIntersections
Properties
Name | |
---|---|
bearings | Type: Array<number> |
classes | Type: Array<string> |
entry | Type: Array<boolean> |
intersection_in | Type: number |
intersection_out | Type: number |
lanes | Type: Array<{ indications: Array<string>,valid: boolean }> |
location | Type: { latitude: number,longtiude: number,name: string } |
Interface StepManeuver
Properties
Name | |
---|---|
bearing_after | Type: number |
bearing_before | Type: number |
coordinate | Type: { latitude: number,longitude: number,name: string } |
instruction Optional | Type: string |
maneuver_type | Type: string |
modifier Optional | Type: string |
muted Optional | Type: boolean |
voice_instruction | Type: Array<{ distance_along_geometry: number,instruction: string,unit: string }> |
Constants ApproachType
Constants | |
---|---|
CURB | route will arrive at the waypoint on the driving_side of the region |
UNRESTRICTED | route can arrive at the waypoint from either side of the road |
Constants AvoidType
Constants | |
---|---|
FERRY | Avoid ferry in route. |
HIGHWAY | Avoid highway in route. |
TOLL | Avoid toll in route. |
Constants TravelMode
The transportation mode for the route.
Constants | |
---|---|
AUTO | default mode, same as car or 4w |
BICYCLING | bike mode |
DRIVING | car mode |
FOUR_WHEELS | four wheels mode |
SCOOTER | scooter mode |
TWO_WHEELs | two wheels mode |
WALKING | walk mode |
Constants GeometryType
Output format of the route geometry.
Constants | |
---|---|
GEOJSON | Geojson format geometry. |
POLYLINE | Polyline format geometry. |
POLYLINE_6 | Polyline6 format geometry. |
Constants OverviewType
Constants | |
---|---|
FALSE | Not include overview in result |
FULL | Include full info in oveview |
SIMPLIFIED | Only inlude simplified info in overview |