Route Services
Contents
Route Path
Given a list of stop coordinates and route options, the route path service will return a list of coordinates that make up the route. The service can be consumed using the getRoutePath
function, on the ALKMaps.Map
class. The parameters are laid out in the table below.
Parameter | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ioformat
| Object
|
Used to specify the input and output formats
| |||||||||
stops
| [String |Array ]
| A list of the route stop's coordinates. | |||||||||
options
| Object
| See routing layer page for a list of available options. |
var stops = [
new ALKMaps.LonLat(-75.339368, 40.11442),
new ALKMaps.LonLat(-74.911539, 40.159933),
new ALKMaps.LonLat(-74.885531, 39.993483),
new ALKMaps.LonLat(-75.191123, 39.802326)
];
stops = ALKMaps.LonLat.transformArray(
stops,
new ALKMaps.Projection("EPSG:4326"),
map.getProjectionObject()
);
map.getRoutePath({
stops: stops,
ioformat: {
input: 1,
output: 1 //this output format tells the service to return and array of ALKMaps.Geometry.Point objects.
},
options: {
vehicleType: "Truck",
routingType: "Practical",
routeOptimization: 1,
highwayOnly: false,
distanceUnits: "Miles",
tollDiscourage: true
}
});
The function returns a list of coordinates in the format specified by the ioformat.output
parameter or in the format [[lon,lat],[lon,lat], ... , [lon,lat], [lon,lat]]
by default.
Route Path with POST Request
Alternatively, you can use the ALKMaps.Services.postRoutePath
to retrieve list of coordinates that make up the route by sending a POST request.
When there are too many parameters, it’s recommended to use POST request as IE Trident and Edge have request length limitations on HTTP GET method.
For a full documentation of request body, please visit API documentation page under Services section.
ALKMaps.Services.postRoutePath({
request: request,
dataset: 0,
success: function(resp) {},
failure: function(resp) {}
});
Derived Route Path
Given a list of ping coordinates and route options, the derived route path service will return a list of derived route points. This service can be consumed using the getDerivedRoutePath
function of the ALKMaps.Map
class. The parameters are essentially the exact same as the getRoutePath
function, aside from the fact that the parameter for the input coordinates is called pings
instead of stops.
var pings = [
new ALKMaps.LonLat(-75.339368, 40.11442),
new ALKMaps.LonLat(-74.911539, 40.159933),
new ALKMaps.LonLat(-74.885531, 39.993483)
];
pings = ALKMaps.LonLat.transformArray(
pings,
new ALKMaps.Projection("EPSG:4326"),
map.getProjectionObject()
);
map.getDerivedRoutePath({
pings: [
[pings[0].lon, pings[0].lat],
[pings[1].lon, pings[1].lat],
[pings[2].lon, pings[2].lat]
],
ioformat: {
input: 2,
output: 2 //this output format tells the service to return a ALKMaps.Geometry.MultiLineString object.
},
options: {
vehicleType: "Truck",
routingType: "Practical",
routeOptimization: 1,
highwayOnly: false,
distanceUnits: "Miles",
tollDiscourage: true
}
});
Derived Route Path with POST Request
Alternatively, you can use the ALKMaps.Services.postDerivedRoutePath
to get a list of derived route points by sending a POST request.
When there are too many parameters, it’s recommended to use POST request as IE Trident and Edge have request length limitations on HTTP GET method.
For a full documentation of request body, please visit API documentation page under Services section.
ALKMaps.Services.postDerivedRoutePath({
request: request,
dataset: 0,
success: function(resp) {},
failure: function(resp) {}
});