Route
Contents
Creates a route component
Param
RouteOptions
Example
var route = new TrimbleMaps.Route({
routeId: 'myRoute',
routeWidth: 8, // or {stops: [[10, 7],[15, 9],[19, 11]]}
stops: [
new TrimbleMaps.LngLat(-74.566234, 40.499440),
new TrimbleMaps.LngLat(-74.629749, 40.261187)
],
routeType: TrimbleMaps.Common.RouteType.SHORTEST,
frameRoute: false,
showStops: false,
overrideClass: TrimbleMaps.Common.ClassOverride.FIFTY_THREE,
requestMethod: TrimbleMaps.Common.RequestMethod.POST
})
.addTo(map);
Extends
Methods
_updateStopsThenGetRoute()
_updateStopsThenGetRoute(
stops
?:Object
[]):void
Gets route after updating stops.
Parameters
Parameter | Type | Description |
---|---|---|
stops ?
| Object []
| Array |
Returns
void
addStopIcon()
addStopIcon(
stopType
:string
,url
:string
):void
Adds stop icon
Parameters
Parameter | Type | Description |
---|---|---|
stopType
| string
| string. Valid values are 'start' , 'end' , 'stop' .
|
url
| string
| string. Icon URL |
Returns
void
addTo()
Attaches the route to a map
Parameters
Parameter | Type | Description |
---|---|---|
map
| Map
| Map. The map used for displaying the route. |
Returns
- Route.
this
canRedo()
canRedo():
boolean
Can redo
Returns
boolean
- boolean. returns true if can redo, otherwise false
canUndo()
canUndo():
boolean
Can undo
Returns
boolean
- boolean. returns true if can undo, otherwise false
disableRouteStack()
disableRouteStack():
void
Disables route undo, redo stack.
Returns
void
enableRouteStack()
enableRouteStack():
void
Enables route undo, redo stack. It is better either enabling undo-redo feature or the removing stop feature. It is not recommended to use both features at the same time.
Returns
void
frame()
frame():
Route
Sets the map view to fit the route.
Returns
- Route.
this
frameRoute()
frameRoute():
Route
Returns
- Route.
this
Deprecated
Sets the map view to fit the route.
getBottomLayerId()
getBottomLayerId():
string
Gets the bottom layer id for this route.
Returns
string
- string. layer id or undefined
getReports()
getReports(
options
:RouteOptions
):void
Gets reports for the route options
Parameters
Parameter | Type | Description |
---|---|---|
options
| RouteOptions
| RouteOptions. The route options used for the reports. |
Returns
void
getRouteId()
getRouteId():
string
Gets the Route ID
Returns
string
- string. ID of the route
getRouteWithNewStop()
getRouteWithNewStop(
newStop
:LngLat
,routeLegPosition
:number
):void
Inserts a stop to a route after a given route leg, then gets the route.
Parameters
Parameter | Type | Description |
---|---|---|
newStop
| LngLat
| LngLat. A stop |
routeLegPosition
| number
| number. The sequence number of a route leg. |
Returns
void
isVisible()
isVisible():
boolean
Returns true if the layer is enabled.
Returns
boolean
- boolean. A boolean indicating the visibility of the layer.
listens()
listens(
type
:string
):boolean
Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.
Parameters
Parameter | Type | Description |
---|---|---|
type
| string
| The event type |
Returns
boolean
true
if there is at least one registered listener for specified event type, false
otherwise
Inherited from
moveLayer()
moveLayer(
beforeId
?:string
):Route
Moves route layers to a different z-position. The route will be inserted before the layer with
ID beforeId
, or appended on the top of the map if beforeId
is omitted.
Parameters
Parameter | Type | Description |
---|---|---|
beforeId ?
| string
| string. Optional ID of an existing layer to insert before |
Returns
- Route.
this
Example
const myRoute1 = new TrimbleMaps.Route();
myRoute1.addTo(map);
myRoute1.moveLayer('layerId');
off()
Removes a previously registered event listener.
Parameters
Parameter | Type | Description |
---|---|---|
type
| string
| The event type to remove listeners for. |
listener
| Listener
| The listener function to remove. |
Returns
Inherited from
on()
on(
type
:string
,listener
:Listener
):this
Adds a listener to a specified event type.
Parameters
Parameter | Type | Description |
---|---|---|
type
| string
| The event type to add a listen for. |
listener
| Listener
| The function to be called when the event is fired. The listener function is called with the data object passed to fire , extended with target and type properties.
|
Returns
this
Inherited from
once()
once(
type
:string
,listener
?:Listener
):Promise
<any
> |Route
Adds a listener that will be called only once to a specified event type.
The listener will be called first time the event fires after the listener is registered.
Parameters
Parameter | Type | Description |
---|---|---|
type
| string
| The event type to listen for. |
listener ?
| Listener
| The function to be called when the event is fired the first time. |
Returns
Promise
<any
> | Route
this
or a promise if a listener is not provided
Inherited from
redo()
redo():
void
Redo route drag
Returns
void
remove()
remove():
Route
Removes the route from a map
Returns
- Route.
this
Example
var route = new TrimbleMaps.Route().addTo(map);
route.remove();
setDraggable()
setDraggable(
isDraggable
:boolean
):Route
Sets the route’s ability to be modified by dragging
Parameters
Parameter | Type | Description |
---|---|---|
isDraggable
| boolean
| boolean. A boolean indicating whether or not the route is draggable. |
Returns
- Route.
this
setEventedParent()
Bubble all events fired by this instance of Evented to this parent instance of Evented.
Parameters
Parameter | Type |
---|---|
parent ?
| Evented
|
data ?
| any
|
Returns
Inherited from
setRouteState()
setRouteState(
isActive
:boolean
):Route
Set the active route opacity 0.6 and enable the drag options and vice versa.
Parameters
Parameter | Type | Description |
---|---|---|
isActive
| boolean
| boolean. A boolean indicating the route is currently visible on the map. |
Returns
- Route.
this
setVisibility()
setVisibility(
isVisible
:boolean
):Route
Set the layer visibility.
Parameters
Parameter | Type | Description |
---|---|---|
isVisible
| boolean
| boolean. A boolean indicating the visibility of the layer. |
Returns
- Route.
this
styleStopIcons()
styleStopIcons(
style
:StyleLayer
):void
Changes stop icons styles. Following properties are assigned internally: id, type, source, layout[‘icon-image’], layout[’text-font’]
Parameters
Parameter | Type | Description |
---|---|---|
style
| StyleLayer
| Objec.t For detailed information, visit the Developer Portal |
Returns
void
toggleVisibility()
toggleVisibility():
Route
Toggle layer visibility.
Returns
- Route.
this
undo()
undo():
void
Undo route drag
Returns
void
update()
update(
options
:RouteOptions
):void
Updates the route. It particularly updates route path, stop icons, route color, route opacity, route width, route arrow, drag routing. If more controlling over route stops styling is desirable, instead of using this function, construct a route with showStops setting to false, then adding custom stops icons uses addStopIcon function and styling them uses styleStopIcons function.
Parameters
Parameter | Type | Description |
---|---|---|
options
| RouteOptions
| RouteOptions. The route options to be updated. |
Returns
void