NavigationService
A service for calculating navigation between locations.
Can be accessed by nextbillion.maps.NavigationService if you load SDK by CDN url.
Methods
| Method | |
|---|---|
| route | route(opt: NavigationRequest) Parameters
Return Value: Promise<null|NavigationResult> Request navigation between an origin and a destination. |
Interface NavigationRequest
A navigation query to be sent to the NavigationSerivce
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. Note: altcount will default to 3 if this is enabled. |
| 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. |
| bearings Optional | Type: Array<NavigationBearingInfo> Limits the search to segments with given bearing in degrees towards true north in clockwise direction. Note: Number of bearings should be equal to the number of coordinates. |
| 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 Optional | Type: LngLatLike Destination is the ending coordinates of your route. Ensure that destination is a valid land location. [This parameter is mandatory IF geometry parameter is not given] |
| geometry Optional | Type: string If this parameter is provided, the only other parameters which will be considered in the request are geometry_type , lang and key . The rest of the parameters will be ignored. |
| geometryType Optional | Type: GeometryType Sets the output format of the route geometry in the response. Default: polyline6 . |
| lang Optional | Type: string language of the text instruction |
| 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. |
| origin Optional | Type: LngLatLike Origin is the starting point of your route. Ensure that origin is a valid land location. [This parameter is mandatory IF geometry parameter is not given] |
| 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. |
| waypoints Optional | Type: Array<LngLatLike> Waypoints are coordinates along the route between Origin and Destination. This is a pipe separated list of coordinate pairs. Default maximum limit is 200 |
Interface NavigationResult
The navigation response retrieved from the navigation server.
Properties
| Name | |
|---|---|
| country_code Optional | Type: string |
| error_msg Optional | Type: string error message if status is not 200. |
| routes Optional | Type: Array<NavigationResponseRoute> 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 NavigationResponseRoute
Properties
| Name | |
|---|---|
| distance | Type: number route driving distance. Unit: meters |
| distance_full Optional | Type: number |
| duration | Type: number route driving duration. Unit: seconds |
| end_location Optional | Type: { latitude: number,longitude: number } end location of route |
| geojson Optional | Type: { coordinates: Array<Array<number>> } |
| geometry Optional | Type: string encoded geometry value for step in polyline or polyline6 . |
| legs | Type: Array<NavigationResponseLeg> legs of route. Note: waypoints split route into legs |
| special_objects Optional | Type: any special geospatial objects crossed along the trip. |
| start_location Optional | Type: { latitude: number,longitude: number } start location of route |
Interface NavigationResponseLeg
Properties
| Name | |
|---|---|
| distance | Type: { value: number } leg driving distance. Unit: meters |
| duration | Type: { value: number } leg driving duration. Unit: seconds |
| end_location Optional | Type: { latitude: number,longitude: number } |
| start_location Optional | Type: { latitude: number,longitude: number } |
| steps | Type: Array<NavigationResponseLegStep> |
Interface NavigationResponseLegStep
Properties
| Name | |
|---|---|
| distance | Type: { value: number } leg driving distance. Unit: meters |
| duration | Type: { value: number } leg driving duration. Unit: seconds |
| 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 NavigationBearingInfo
Properties
| Name | |
|---|---|
| degree | Type: number |
| range | Type: number |
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 |
| CAR | car mode |
| TRUCK | truck 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 |