Routing Layer
Contents
The L.ALKMaps.Layer.Routing layer is used to retrieve, display, and get reports for routes.
Add A Route
Once you have added a routing layer to your map, you can begin adding routes to the layer. The addRoute function of the routing layer has up to six parameters: stops, options, functionOptions, reportOptions, and the success and failure callback functions. Descriptions for these parameters can be found in the table below.
Stops
The stops parameter of the addRoute method should contain an array of L.latLng objects representing the stops of the route.
Options
The options parameter contains options related to the generation of the route and optional reports.
| Parameter | Type/Values | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| vehicleType | [0 | 1 | 2] | Default: 0 Restricts the route to roads that are accessible by the selected vehicle type. 
 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| routingType | [0 | 1 | 2] | Default: 0 Generated the route to match the type. 
 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| routeOptimization | [0 | 1 | 2] | Default: 0 
 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tollDiscourage | boolean | Default: false Generates the route by trying to avoid toll roads. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tollRoads | [1 | 2 | 3] | Default: Null Indicates whether or not to avoid toll roads when generating a route. If this parameter is specified, the value in tollDiscouragewill be ignored. If this parameter is null, the value intollDiscouragewill be used. Available indataVersionPCM34 and Later. UsetollDiscouragefor older versions.
 classOverrides[0 | 1 | 2 | 3]Default: 0 | 
 bordersOpenbooleanDefault: true | Set to Trueto allow international border crossings,Falseto avoid or reduce number of international border crossings. For example, if all your stops are in the “lower 48” United States, the resulting route will stay in the United States even if the most practical or shortest route would normally involve some Canadian mileage. For EU travel, setting this toFalsewill reduce the number of EU border crossings where possible and the route will follow the best path within the country from which the route originates.overrideRestrictbooleanDefault: false | Indicates whether or not to override truck restrictions highwayOnlybooleanDefault: false | Restricts the route to only highway roads. hazMatTypeArray of [0 | 1 | 2 | 3 | 4 | 5 | 6 | 7]Default: 0 | Restricts the route to roads that allow transportation of the selected hazardous material. North America 
 
 tunnelCategoryArray of [0 | 1 | 2 | 3 | 4]Default: 0 | Indicates the tunnel categories, which are applicable for EU region only. 
 governorSpeedLimitnumberMaximum average road speed to use in route calculations that overrides all other road speeds when they are above this value.
Default is disabled and valid value is between 1 and 100 mph or 1 and 161 kph based on | distanceUnits.avoidStateArray of stringDefault: empty list | A comma-separated list of ISO2 codes for states that should be avoided when generating a route. Default is an empty list. This parameter is for North America only. Available in PCM34 and Later. Examples: ['NJ', 'PA'] avoidCountryArray of stringDefault: empty list | A comma-separated list of ISO2 codes for countries that should be avoided when generating a route. Default is an empty list. Available in PCM34 and Later. Examples: ['BE', 'AT'] favorStateArray of stringDefault: empty list | A comma-separated list of ISO2 codes for states that should be favored when generating a route. Default is an empty list. This parameter is for North America only. Available in PCM34 and Later. Examples: ['NJ', 'PA'] favorCountryArray of stringDefault: empty list | A comma-separated list of ISO2 codes for countries that should be favored when generating a route. Default is an empty list. This parameter is for regions outside of North America. Available in PCM34 and Later. Examples: ['BE', 'AT'] distanceUnits[0 | 1]Default: 0 | Distance units as miles or kilometers. 
 trkUnits[0 | 1]Default: 0 | Vehicle dimension units; can be English or Metric. 
 trkHeightnumberThe height of the vehicle in feet and inches or meters depending on
units. Example 13'6" or 4.1148. | trkLengthnumberThe length of the vehicle in feet and inches or meters depending on
units. Example 13'6" or 4.1148. | trkWidthnumberThe width of the vehicle in feet and inches or meters depending on
units. Example 13'6" or 4.1148. | trkWeightnumberThe weight of the vehicle in pounds or kilograms depending on units. | trkAxlesnumberDefault: 5 | The number of axles on the vehicle; acceptable values are 2 through 14. inclFerryDistbooleanDefault: true | Indicates whether or not to include ferry distances in mileage calculations. fuelUnits[0 | 1]Default: 0 | Fuel units as gallons and liters. 
 truckConfig[0 | 1 | 2 | 3 | 4]Default: 0 | The vehicle style. 
 inclTollDatabooleanDefault: true | Indicates whether or not reports should calculate toll costs. fuelEconLoadnumberThe fuel efficiency (distance units per fuel units) when loaded. | fuelEconEmptynumberThe fuel efficiency (distance units per fuel units) when empty. | costPerFuelUnitnumberThe cost per fuel unit of fuel. | costGHGnumberThe cost of greenhouse gas in lbs. per fuel unit. | costMaintLoadnumberThe maintenance cost per distance unit when loaded. | costMaintEmptynumberThe maintenance cost per distance unit when empty. | costTimeLoadnumberThe time cost per mile/km when loaded. | costTimeEmptynumberThe time cost per mile/km when empty. | tollCurrency[0 | 1]Default: 0 | The toll currency. 
 exchangeRatenumberThe change rate to convert US dollars to Canadian dollars. | citeIntnumberThe cite interval to be used when generating a geotunnel report. The
minimum value is 0.1. | region[NA | EU | OC | SA | AS | AF | ME]Default: NA | The data region in which the route stops are located. Note: If region is not provided, region value will be inherited from baseLayer region parameter. dataset | [Current | PCM_EU | PCM_OC | PCM_SADefault: Current | For users licensed for multiple regional datasets. | 
Function Options
The functionOptions parameter contains options related to the functionality of the actual layer.
| Parameter | Type/Values | Description | 
|---|---|---|
| routeId | String | User defined id for the route. | 
| style | Object | Object containing styling properties to be used for the visualization of the route. If not provided, one of the predefined route styles will be used. | 
| frameRoutes | Boolean | Determines whether or not the map will zoom to fit all the routes on the layer. Default: true | 
| showHandles | Boolean | Determines whether or not to display the graphics that normally display at each of the route’s stops. Default: true | 
Report Options
The reportOptions parameter contains options related to the creation of the different route reports and formats.
| Parameter | Type/Values | Description | 
|---|---|---|
| type | [Mileage / Directions / Detail / State / CalcMiles / LeastCost / Geotunnel] | Comma-separated list of requested report types. | 
| format | [json / html] | Default: json The format of the report returned with the route. | 
Arrows Along Route
The following piece of sample code demonstrates a route with arrows. The plugin is provided by Benjamin Becquet.