ALKMaps.Layer.Routing

Create a vector layer for drawing and managing route objects.

Inherits from

Summary
ALKMaps.Layer.RoutingCreate a vector layer for drawing and managing route objects.
Properties
dragControlProperty containing the ALKDragFeature control associated with this layer.
isDraggableProperty indicating whether or not the routes on the layer are draggable.
dragQueueMaxSizeProperty indicating undo, redo drag queue size for each route on the layer.
originDefaultProperty containing the location of an external image to be used as the default image for all origin handles.
destinationDefaultProperty containing the location of an external image to be used as the default image for all destination handles.
waypointDefaultProperty containing the location of an external image to be used as the default image for all waypoint handles.
Constructor
ALKMaps.Layer.RoutingCreate a vector layer for drawing and managing route objects.
Functions
setMapThe layer has been added to the map.
addRouteDragHandle
getRouteLegPointsDraw route with stops on this layer.
addRouteAdds a route object and draws it on this layer.
removeRouteRemoves a route from the layer by id.
updateRouteUpdates a route object and draws it on the layer.
getRouteElementsGets the ALKMaps vector elements for the route stops and segments drawn on the layer.
getRouteOptionsGets all the parameters that are set when the route is added.
updateNodeStores feature Id.
getGeometryGets drag handle geometry.
getPreviousHandleGets drag handle after this one.
getNextHandleGets drag handle before this one.
getNodesGets nodes that are connected to the drag handle.
getDragHandleFromNodeGets drag handles from the node.
isStartHandleDetermines a drag handle is a route start point or not.
isEndHandleDetermines a drag handle is a route end point or not.
getHandleActionDetermines which drag handle has been dragged.
setDraggableSets the layer’s ability to have routes be modified by dragging.
setRouteHandleVisibilitySets the visibility of all stop markers and the showHandles option of the route.
setRouteHandleSets the style of the route handles by type or index.
setRouteVisibilityMethod for toggling the visibility of the lines and handles of a given route.
onRouteModifiedCallback method.
onErrorRouteModificationCallback method.
canUndoStill has record in the queue for undo dragged route.
canRedoStill has record in the queue for redo dragged route.
undoDragUndo route drag for a given route id.
redoDragRedo route drag for a given route id.
clearDragQueueClear undo/redo route drag queue for a given route id.
redrawRedraws the layer, and reconfigures the arrows of all existing routes with arrows.
drawArrowsFirst removes any existing arrows on the specified route.
createArrowCreates a new arrow feature using the given Point geometry, style, rotation, and routeId.

Properties

dragControl

Property containing the ALKDragFeature control associated with this layer.

isDraggable

Property indicating whether or not the routes on the layer are draggable.

dragQueueMaxSize

Property indicating undo, redo drag queue size for each route on the layer.  When isDraggable is set to true, this property may be considered.  Must start with 2, then first drag can be undone.

originDefault

Property containing the location of an external image to be used as the default image for all origin handles.

destinationDefault

Property containing the location of an external image to be used as the default image for all destination handles.

waypointDefault

Property containing the location of an external image to be used as the default image for all waypoint handles.

Constructor

ALKMaps.Layer.Routing

Create a vector layer for drawing and managing route objects.

Parameters

name{String} Unique layer name.
options{Object} Properties to set on this layer.

Valid options

isDraggable{Boolean} Value true may enable route line dragging.
originURL{String} Custom URL for trip origin icon.
waypointURL{String} Custom URL for waypoints icon.
destinationURL{String} Custom URL for trip destination icon.
dragQueueMaxSize{Number} Optional.  Property indicating undo, redo drag queue size for each route on the layer.  When isDraggable is set to true, this property may be considered.

Returns

{ALKMaps.Layer.Routing} A new vector layer for drawing and managing route objects.

Functions

setMap

setMap: function()

The layer has been added to the map.

addRouteDragHandle

addRouteDragHandle: function(handleState,
legCoords,
isVisible,
extImg)
Add drag handlesroute begin, route end and waypoint handle.

getRouteLegPoints

getRouteLegPoints: function(args,
isRail,
removeExistingFeatures)

Draw route with stops on this layer.  When undo/redo drag route happens, clear existing features for the route, without re-frame the route.  Added isRail parameter in April, 2017.  Added removeExistingFeatures parameter in June 25, 2019.

Parameters

args{Object}
isRail{Boolean}
removeExistingFeatures{Boolean} When set to true in case of undo/redo drag route, clear existing features for the route, without re-frame route.

addRoute

addRoute: function(args)

Adds a route object and draws it on this layer.

Parameters

args{Object} with {stops: Object, routeOptions: Object, reportOptions: Object, functionOptions: Object, externalImages: Object}
stops{Array(ALKMaps.LonLat)}
routeOptions{Object} ALK Map service supported options.  See supported route options bellow.
reportOptions{Object} type: Type value can be Mileage, Directions, Detail, State, CalcMiles, LeastCost, Geotunnel.  format: Format value can be json or html.  dataVersion: data version value can be Current, PCM_EU, PCM_OC, PCM_SA, PCM_GT, PCM_AF, PCM_AS, PCM_ME, or PCM18 through PCM27 lang: The language.  ENUS for English United States, ENGB for English Great Britain, DE for German, FR for French, ES for Spanish, IT for Italian
externalImages{Object}
images{Array(Strings)} Array of image locations that is the same size as the stops array.  (optional)
functionOptions{Object} has routeId {String}, async {Boolean}, style {ALKMaps.Feature.Vector.style} and callback function.  routeId: is used to uniquely identify a route.  async: determines if server call is asynchronous or not.  Default is asynchronous.  style: If this is provided, it will override class level style.  User can supply strokeOpacity, strokeColor, strokeLinecap, strokeWidth, and strokeDashstyle.  Stroke opacity value range is from 0 to 1.  Stroke color takes hex code in string, like “#ee9900”.  Valid value for line cap is “butt”, “round”, or “square”.  Valid value for dash style is “dot”, “dash”, “dashdot”, “longdash”, “longdashdot” or “solid” and most SLD patterns will render correctly.  If stroke width is supplied, default width in the context will be replaced. callback function: called when results are returned from server.  Returned values can be report and updated stops.

removeRoute

removeRoute: function(routeId)

Removes a route from the layer by id.

Parameters

routeId:{String} the same id that is used to add the route to the layer.

updateRoute

updateRoute: function(args)

Updates a route object and draws it on the layer.  If stops, functional options, or report options are not included, it will use the parameters from the original route.

Parameters

args:{Object} with {stops: Object, routeOptions: Object, reportOptions: Object, functionOptions: Object}
stops{Array(ALKMaps.LonLat)}
routeOptions{Object} ALK Map service supported options.  See supported route options bellow.
reportOptions{Object} has type and format two keys.  Type value can be mileage, directions, detailed or stateMileage.  Format value can be json, xml, or html.
functionOptions{Object} has routeId (String), async (Boolean), style (ALKMaps.Feature.Vector.style) and callback function.  Route Id is used to uniquely identify a route.  Async: determines if server call is asynchronous or not.  Default is asynchronous. style: If this is provided, it will override class level style.  Only strokeOpacity, and strokeColor are allowed to change. callback function: called when results are returned from server.  Returned values can be report and updated stops.

getRouteElements

getRouteElements: function(routeId)

Gets the ALKMaps vector elements for the route stops and segments drawn on the layer.

Parameters

routeId:{String} the same id that is used to add the route to the layer.

Returns

Point and line vectors.

getRouteOptions

getRouteOptions: function(routeIndex)

Gets all the parameters that are set when the route is added.

Parameters

routeId:{String} route id.

Returns

args:{stops, routeOptions, reportOptions, functionOptions}

stops: {Array(ALKMaps.LonLat)}

routeOptions: ALK Map service supported options.  See supported route options bellow.

reportOptions: has type and format two keys.  Type value can be mileage, directions, detailed or stateMileage.  Format value can be json, xml, or html.

functionOptions: has routeId (String), async (Boolean), style (ALKMaps.Feature.Vector.style) and callback function.  Route Id is used to uniquely identify a route.  Async: determines if server call is asynchronous or not.  Default is asynchronous. style: If this is provided, it will override class level style. callback function: called when results are returned from server.  Returned values can be report and updated stops.

updateNode

updateNode: function(oldOne,
newOne)

Stores feature Id.

getGeometry

getGeometry: function(handle)

Gets drag handle geometry.

getPreviousHandle

getPreviousHandle: function(hd)

Gets drag handle after this one.

getNextHandle

getNextHandle: function(hd)

Gets drag handle before this one.

getNodes

getNodes: function(hd)

Gets nodes that are connected to the drag handle.

getDragHandleFromNode

getDragHandleFromNode: function(nd)

Gets drag handles from the node.

isStartHandle

isStartHandle: function(hd)

Determines a drag handle is a route start point or not.

isEndHandle

isEndHandle: function(hd)

Determines a drag handle is a route end point or not.

getHandleAction

getHandleAction: function(hd)

Determines which drag handle has been dragged.

setDraggable

setDraggable: function(isDraggable)

Sets the layer’s ability to have routes be modified by dragging.

Parameters

isDraggable{boolean} Indicates whether the routes should be draggable.

setRouteHandleVisibility

setRouteHandleVisibility: function(routeId,
showHandles)

Sets the visibility of all stop markers and the showHandles option of the route.

Parameters

routeId{String} The routeID of the route.
showHandles{boolean} Indicates whether the stop markers are displayed.

setRouteHandle

setRouteHandle: function(routeId,
stop,
handleOptions)

Sets the style of the route handles by type or index.

Parameters

routeId{String} The routeID of the route.
stop{“O” | “W” | “D” | number} Indicates the type or index of the stop.
handleOptions{Object} Object containing style properties to be set.
  • externalGraphic - URL of the route handle image
  • graphicWidth - width of the image
  • graphicHeight - height of the image
  • graphicXOffset - X offset from the stop point
  • graphicYOffset - Y offset from the stop point

setRouteVisibility

setRouteVisibility: function (routeId,
showRoute)

Method for toggling the visibility of the lines and handles of a given route.

Parameters

routeId{String} ID of the route
showRoute{Boolean} Indicates whether to show or hide the given route.

onRouteModified

onRouteModified: function(obj)

Callback method.  Called when results are returned after a route dragging is completed.  Returns report and updated stop lists.

routingLayer.onRouteModified = function (results) {
    // user implementation
};

onErrorRouteModification

Callback method.  Allows user to handle route modification error.

routingLayer.onErrorRouteModification = function (response) {
    // user implementation
};

canUndo

canUndo: function(routeId)

Still has record in the queue for undo dragged route.  Caller can enable/disable undo button as an example from the returned value of this method call.

Parameters

routeId{String} ID of the route

canRedo

canRedo: function(routeId)

Still has record in the queue for redo dragged route.  Caller can enable/disable undo button as an example from the returned value of this method call.

Parameters

routeId{String} ID of the route

undoDrag

undoDrag: function (routeId)

Undo route drag for a given route id.

Parameters

routeId{String} ID of the route

redoDrag

redoDrag: function (routeId)

Redo route drag for a given route id.

Parameters

routeId{String} ID of the route

clearDragQueue

clearDragQueue: function (routeId)

Clear undo/redo route drag queue for a given route id.

Parameters

routeId{String} ID of the route

redraw

redraw: function ()

Redraws the layer, and reconfigures the arrows of all existing routes with arrows.  removes any existing route arrows before drawing new ones in the appropriate locations.

drawArrows

drawArrows: function (arrowsObj)

First removes any existing arrows on the specified route.  Then either draws new arrows along the route line at a given spacing interval or draws a single arrow at the end of the route.

Parameters

arrowsObj{Object} Object containing an array of arrow point features and the ID of the route that the arrows correspond to.

createArrow

createArrow: function(point,
style,
bearing,
routeId)

Creates a new arrow feature using the given Point geometry, style, rotation, and routeId.

Parameters

point{ALKMaps.Geometry.Point} Arrow feature’s point geometry.
style{Object} Route’s style object.
bearing{Number} Rotation of arrow.
routeId{String} ID of the route that the arrow corresponds to.

Returns

{ALKMaps.Feature.Vector} New arrow feature.

setMap: function()
The layer has been added to the map.
addRouteDragHandle: function(handleState,
legCoords,
isVisible,
extImg)
getRouteLegPoints: function(args,
isRail,
removeExistingFeatures)
Draw route with stops on this layer.
addRoute: function(args)
Adds a route object and draws it on this layer.
removeRoute: function(routeId)
Removes a route from the layer by id.
updateRoute: function(args)
Updates a route object and draws it on the layer.
getRouteElements: function(routeId)
Gets the ALKMaps vector elements for the route stops and segments drawn on the layer.
getRouteOptions: function(routeIndex)
Gets all the parameters that are set when the route is added.
updateNode: function(oldOne,
newOne)
Stores feature Id.
getGeometry: function(handle)
Gets drag handle geometry.
getPreviousHandle: function(hd)
Gets drag handle after this one.
getNextHandle: function(hd)
Gets drag handle before this one.
getNodes: function(hd)
Gets nodes that are connected to the drag handle.
getDragHandleFromNode: function(nd)
Gets drag handles from the node.
isStartHandle: function(hd)
Determines a drag handle is a route start point or not.
isEndHandle: function(hd)
Determines a drag handle is a route end point or not.
getHandleAction: function(hd)
Determines which drag handle has been dragged.
setDraggable: function(isDraggable)
Sets the layer’s ability to have routes be modified by dragging.
setRouteHandleVisibility: function(routeId,
showHandles)
Sets the visibility of all stop markers and the showHandles option of the route.
setRouteHandle: function(routeId,
stop,
handleOptions)
Sets the style of the route handles by type or index.
setRouteVisibility: function (routeId,
showRoute)
Method for toggling the visibility of the lines and handles of a given route.
onRouteModified: function(obj)
Callback method.
canUndo: function(routeId)
Still has record in the queue for undo dragged route.
canRedo: function(routeId)
Still has record in the queue for redo dragged route.
undoDrag: function (routeId)
Undo route drag for a given route id.
redoDrag: function (routeId)
Redo route drag for a given route id.
clearDragQueue: function (routeId)
Clear undo/redo route drag queue for a given route id.
redraw: function ()
Redraws the layer, and reconfigures the arrows of all existing routes with arrows.
drawArrows: function (arrowsObj)
First removes any existing arrows on the specified route.
createArrow: function(point,
style,
bearing,
routeId)
Creates a new arrow feature using the given Point geometry, style, rotation, and routeId.
Instances of ALKMaps.Layer.Vector are used to render vector data from a variety of sources.
Create a vector layer for drawing and managing route objects.
This class represents a longitude and latitude pair
{Object}
Point geometry class.
Vector features use the ALKMaps.Geometry classes as geometry description.
Close