Extends: L.Class
Options | Type | Description |
---|---|---|
options | object | Directions options object |
Option | Type | Default | Description |
---|---|---|---|
accessToken |
String | null |
Required unless L.mapbox.accessToken is set globally |
profile |
String | mapbox.driving |
Routing profile to use. Options: mapbox.driving , mapbox.walking , mapbox.cycling |
units |
String | imperial |
Measurement system to be used in navigation instructions. Options: imperial , metric |
Event | Content |
---|---|
origin |
Fired when the origin is selected. |
destination |
Fired when the destination is selected. |
profile |
Fired when a profile is selected. |
selectRoute |
Fired when a route is selected. |
highlightRoute |
Fired when a route is highlighted. |
highlightStep |
Fired when a step is highlighted. |
load |
Fired when directions load. |
error |
Fired when remote requests result in an error. |
Returns the origin of the current route.
Returns: the origin
Sets the origin of the current route.
Returns: this
Returns the destination of the current route.
Returns: the destination
Sets the destination of the current route.
Returns: this
Returns: boolean
, whether both the destination and the origin are set properly
and directions can be retrieved at this time.
After you've set an origin and destination, query
fires the query to geocoding
and sets results in the controller.
Options is an optional options object, which can specify:
proximity
: a L.LatLng object that is fed into the geocoder and biases matches around a point
Callback is an optional callback that will be called with (err, results)
Returns: this
Add a waypoint to the route at the given index. waypoint
can be a GeoJSON Point Feature or a L.LatLng
.
Returns: this
Remove the waypoint at the given index from the route.
Returns: this
Change the waypoint at the given index. waypoint
can be a GeoJSON Point Feature or a L.LatLng
.
Returns: this
Swap the origin and destination.
Returns: this
Send a directions query request. opts
can contain a proximity
LatLng object for geocoding origin/destination/waypoint strings.
Returns: this
Extends: L.LayerGroup
Create a new layer that displays a given set of directions on a map.
Options | Value | Description |
---|---|---|
options | object | Layer options object |
Option | Type | Default | Description |
---|---|---|---|
readonly |
Boolean | false |
Optional. If set to true marker and linestring interaction is disabled. |
routeStyle |
Object | {color: '#3BB2D0', weight: 4, opacity: .75} |
GeoJSON style to specify color , weight and opacity of route polyline. |
Add this control to a given map object.
Returns: this
Add this control to a given map object.
Returns: this
Add this control to a given map object.
Returns: this