ALKMaps.Layer.Routing (Leaflet)

The ALKMaps routing layer.

Inherits from

  • <L.Class>
Summary
ALKMaps.Layer.Routing (Leaflet)The ALKMaps routing layer.
Properties
map{L.Map} the map
Constructor
L.ALKMaps.Layer.RoutingInitializes a new L.ALKMaps.Layer.Routing object
Functions
addRouteAdds a route to the map
removeRouteRemoves a route from the layer by id.
updateRouteUpdates a route object and draws it on the layer.
routingCreate a new ALKMaps.Layer.Routing instance

Properties

map

{L.Map} the map

Constructor

L.ALKMaps.Layer.Routing

Initializes a new L.ALKMaps.Layer.Routing object

Parameters

Functions

addRoute

addRoute: function (params)

Adds a route to the map

Parameters

stops{Array<L.latLng>} List of route stop coordinates
options{Object} ALK Maps routing service options.  A detailed list of routing options can be seen below.
functionOptions{Object} Options pertaining to the functionality of the layer.  See details below.
reportOptions{Object} Options for route reports.  Detailed list of options shown below.
success{Function} Function handles success asynchronous service response.
failure{Function} Function handles failure asynchronous service response.

Valid options include

region{String} The data region in which pings are located.  Choices are NA; AF, AS, EU, NA, OC ,SA and ME for world-wide.  AF indicates Africa, AS indicates Asia, EU indicates Europe, NA indicates the North America, OC indicates Oceania, SA indicates South America.  The default is NA.
dataset{String} For users licensed for multiple regional datasets, this parameter will allow you to choose between PCM_EU, PCM_OC, PCM_SA or Current (default)
highwayOnly{Boolean} To indicate whether to use highway only routing or not.  The default is false.
vehicleType{String} The vehicle type which can be Truck (0), LightTruck (1) or Auto (2).
routingType{String} The desired routing algorithm which can be Practical (0) or Shortest (1).
classOverrides{String} A comma-separated list of class overrides which can be None (0x0), NationalNetwork (0x1) and/or FiftyThreeFoot (0x2).  Default is None.
distanceUnits{String} Distance units as Miles (0) or Kilometers (1).
tollDiscourage{Boolean} Indicates whether or not to avoid tolls while routing; can be true or false.  Default is false.
bordersOpen{Boolean} Indicates whether borders are open for travel; can be true or false.
overrideRestrict{Boolean} Indicates whether or not to override truck restrictions; can be true or false.  Default is false.
hazMatType{String} Indicates the hazardous material type; can be None (0), General (1), Caustic (2), Explosives (3), Flammable (4), Inhalants (5), Radioactive (6), HarmfulToWater (7).
tunnelCategory{Number} Indicates the tunnel categories which are applicable for EU region only.  Values can be None (0), TunnelBCDE (1), TunnelCDE (2), TunnelDE (3), TunnelE (4).
trkUnits{String} Vehicle dimension units; can be English (0) or Metric (1).
trkHeight{Number} The height of the truck in feet and inches or meters depending on units.  The default is 13’6” in all regions except Europe, which is 12’6”.  Example 13’6” or 4.1148.
trkLength{Number} The length of the truck in feet and inches or meters depending on units.  Default is 48 feet in all regions except Europe, which is 54’1”.  Example 13’6” or 4.1148.
trkWidth{Number} The width of the truck in feet and inches or meters depending on units.  This value can be 96” and below, 102” and above or 98”.  The default value is 96” for all regions.  Example 13’6” or 4.1148.
trkWeight{Number} The weight of the truck in pounds or kilograms depending on units.  Acceptable values can be up to 132,000 pounds or 59,874 kilos.  The default value is 80,000 pounds for all regions.
trkAxles{Number} The number of axles on the truck; acceptable values are 2 through 14 and the default value is 5.
trkLCV{Boolean} Indicates whether the truck is a multi-trailer or longer combination vehicle; can be true or false.
routeOptimization{String} Indicates the method by which to optimize route stops; can be None (0), ThruAll (1) or DestinationFixed (2).
hubRouting{Boolean} Indicates whether or not to enable hub routing; can be true or false.

Valid function options include

id{String} User defined route identifier.
style{Object} Object containing styling properties to be used for the route vector, if not provided one of the predefined routing styles will be used.
showHandles{Boolean} Determines whether or not to display the default route handle images.  Default: true
frameRoutes{Boolean} Determines whether or not the map will zoom to fit all the routes on the layer.  Default: true

Valid report options include

type{String} Comma delimited string of report types.  Depending on permissions type value can be Mileage, Directions, Detail, State, CalcMiles, LeastCost, or Geotunnel.  Example: “Directions,Mileage”
format{String} Return format for the report.  Valid formats are “json” or “html”.
dataVersion{String} Data version value can be Current, PCM_EU, PCM_OC, PCM_SA, PCM_GT, PCM_AF, PCM_AS, PCM_ME, or PCM18 through PCM27

Example

routingLayer.addRoute({
     stops: [L.latLng(40.40347,-74.64840),L.latLng(40.367494, -74.655522), L.latLng(39.822326,-75.191123)],
     options: {
         region: "NA",
         dataset: "Current",
         vehicleType: "Truck",
         routingType: "Practical",
         highwayOnly: false,
         tollDiscourage: true
     },
     functionOptions: {
         showHandles: false,
         frameRoutes: true,
         style: { opacity: 0.6, color: "#2448ff", weight: 20 }
     },
     reportOptions: {
         "type": "Directions,Mileage,Detail,State",
         "format": "html",
         "dataVersion": "PCM_EU"
     },
     success: function(resp){
         console.log(resp);
     },
     failure: function(resp){
         var text = resp.responseText;
         console.log(text);
     }
});

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 (params)

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

stops{Array<L.latLng>} List of route stop coordinates
options{Object} ALK Maps routing service options.  A detailed list of routing options can be seen below.
functionOptions{Object} Options pertaining to the functionality of the layer.  See details below.
reportOptions{Object} Options for route reports.  Detailed list of options shown below.
success{Function} Function handles success asynchronous service response.
failure{Function} Function handles failure asynchronous service response.

routing

layer.routing = function (map)

Create a new ALKMaps.Layer.Routing instance

Parameters

var routingLayer = L.ALKMaps.Layer.routing({});

Returns

{Object} An instance of L.ALKMaps.Layer.Routing

addRoute: function (params)
Adds a route to the map
removeRoute: function (routeId)
Removes a route from the layer by id.
updateRoute: function (params)
Updates a route object and draws it on the layer.
layer.routing = function (map)
Create a new ALKMaps.Layer.Routing instance
Close