ALKMaps.Services

A utility class can be used to consume ALK mapping, geocoding, and routing services.

Summary
ALKMaps.ServicesA utility class can be used to consume ALK mapping, geocoding, and routing services.
Functions
getCustomPlaceGet custom places for a given account.
updateCustomPlaceSetUpdate custom place set’s name, and tag for a given set id and tag.
deleteCustomPlaceSetDelete custom place set for a given id.
deleteCustomPlaceDelete custom place.
getCustomCategoriesGet custom categories.
addCustomCategoryAdd custom category.
updateCustomCategoryUpdate custom categories.
getReportsTakes coords objects and report options, return total time and total distance synchronously.
getRoutePathTakes coords objects and route options, return lat/lons for the route path.
addAvoidFavorSetAdd a new avoid/favor set.
getAvoidFavorSetsRetrieves all AvoidFavorSets, one specific set if the setId is specified.
updateAvoidFavorSetUpdate name and tag based on set Id.
deleteAvoidFavorSetDeletes the AvoidFavor set.
addAvoidFavorAdd a new set with closure.
deleteAvoidFavorDeletes a specific AvoidFavors within a set.

Functions

getCustomPlace

services.getCustomPlaces = function (inputs)

Get custom places for a given account.

Parameters

inputs{Object} Accept id, tag and bounds properties.

Valid inputs include

id{Number} Custom places set id.
tag{String} Custom places set tag.  (optional)
bounds{ALKMaps.Bounds} Tile bounds for custom places within this box.
placeName{String} refine the results by optional custom place name.  (optional)
catId{Number} refine the results by optional custom category id.  (optional)
catName{String} refine the results by optional custom category name.  (optional)
success{function} callback function called after success with the return object as a parameter.  (optional)
failure{function} callback function called after failure with the return object as a parameter.  (optional)
ALKMaps.Services.getCustomPlaces({
    id: 82,
    catId: 61,
    bounds: {left: -80,top: 40,bottom: 50,right: -70},
    success: function(response){}
});

Returns

An example of retured object [{“SetID”:9,”SetName”:”Walmart”,”SetTag”:”AccountId:3”,”CustomPlaces”:[{“Address”:{“StreetAddress”:”1400 W WABANSIA AVE”,”City”:”CHICAGO”,”State”:””,”Zip”:”60622”,”County”:”US”,”Country”:null,”SPLC”:null,”CountryPostalFilter”:0,”AbbreviationFormat”:0},”Coords”:{“Lat”:”41.913408”,”Lon”:”-87.663022”},”Region”:4,”Label”:null,”PlaceName”:”TACTICA INTERNATIONAL LLC 3”,”PlaceId”:185186,”PlaceType”:null,”Phone”:null,”Category”:null}]}]

updateCustomPlaceSet

services.updateCustomPlaceSet = function(inputs)

Update custom place set’s name, and tag for a given set id and tag.

Parameters

inputs{Object}

Valid inputs include

id{Number} the existing custom place set id.
name{String} the new name you want to assign to the set.
tag{String} the new tag you want to assign the set.
success{function} callback function called after success with the return object as a parameter.  (optional)
failure{function} callback function called after failure with the return object as a parameter.  (optional)

Returns

{Number} The number of rows affected.

deleteCustomPlaceSet

services.deleteCustomPlaceSet = function(inputs)

Delete custom place set for a given id.

Parameters

inputs{Object}

Valid inputs include

id{Number} the existing custom place set id.
success{function} callback function called after success with the return object as a parameter.  (optional)
failure{function} callback function called after failure with the return object as a parameter.  (optional)

Returns

{Number} The number of rows affected.

deleteCustomPlace

services.deleteCustomPlace = function(inputs)

Delete custom place.  User needs to supply the set ID and the place ID and it will delete only place IDs in that set, otherwise error.

Parameters

inputs{Object}

Valid inputs include

setId{Number} ID of set that the custom place is in.
placeId{Number} ID of the custom place.
success{function} callback function called after success with the return object as a parameter.  (optional)
failure{function} callback function called after failure with the return object as a parameter.  (optional)

Returns

{Number} The number of rows affected.

getCustomCategories

services.getCustomCategories = function(inputs)

Get custom categories.

Parameters

inputs{Object}

Valid inputs include(if no inputs are specified, the first 63 categories will be returned)

id{Number} Category ID number.  (optional)
tag{String} Category tag of one or more categories.  (optional)
name{String} Category name of one or more categories.  (optional)
success{function} callback function called after success with the return object as a parameter.  (optional)
failure{function} callback function called after failure with the return object as a parameter.  (optional)

Returns

[{ “Id”: number, “Name”: string, “Icon”: string, “IconURL”: string, “Tag”: string }]

addCustomCategory

services.addCustomCategory = function(inputs)

Add custom category.

Parameters

inputs{Object}

Valid inputs include

categoryToAdd{Object}

Valid category object includes

name{String} name of category.
icon{String} name of category icon.
iconURL{String} image URL of category icon.
tag{String} category tag.
success{function} callback function called after success with the return object as a parameter.  (optional)
failure{function} callback function called after failure with the return object as a parameter.  (optional)

Returns

{Number}category id.

updateCustomCategory

services.updateCustomCategory = function(inputs)

Update custom categories.

Parameters

inputs{Object}

Valid inputs include

categoryToUpdate{Object} Array of custom categories.

Valid category object includes

id{Number} Category ID.
name{String} Category name.
icon{String} Optional new icon name, but if no value is specified the field will be set to null.  (optional)
inconURL{String} Optional new icon image URL, but if no value is specified the field will be set to null.  (optional)
tag{String} Optional new category tag, but if no value is specified the field will be set to null.  (optional)
success{function} callback function called after success with the return object as a parameter.  (optional)
failure{function} callback function called after failure with the return object as a parameter.  (optional)

Returns

{Number}The number of rows affected.

getReports

services.getReports = function (params)

Takes coords objects and report options, return total time and total distance synchronously.  Todo

Parameters

inputs{Object} Todo

Valid inputs include

coords{Array of decimal pairs} Coordinates of the start, end, and any waypoints for the given route.
options{Object} optional function specification settings.
reportOptions{Object} optional reporting specification settings.

Valid options include

vehicleType{Number} Restricts the route to roads that are accessible by the selected vehicle.  Default: 0 (0 - Truck, 1 - Light Truck, 2 - Automobile)
routingType{Number} Generates the route to match the type.  Default: 0 (0 - Practical, 1 - Shortest)
highwayOnly{Boolean} Restricts the route to only highway roads.  Default: false
custRdSpeeds{Boolean} Can be true or false and indicates whether to use custom road speeds.
useAvoidFavors{Boolean} Can be true or false and indicates whether or not to use avoids and favors while routing.
classOverrides{Number} 0 - Indicates that no class overrides are present, 1 - Indicates a 53’ class override, 2 - Indicates a National Network class override.  Default: 0
distanceUnits{Number} Distance units as miles or kilometers.  Default: 0 (0 - Miles, 1 - Kilometers)
fuelUnits{Number} Fuel units as gallons and liters.  Default: 0 (0 - Gallons, 1 - Liters) //Why is ‘liters’ being spelled ‘litters’!!!
tollDiscourage{Boolean} Generates the route by trying to avoid toll roads.  Default: false
inclFerryDist{Boolean} Indicates whether or not to include ferry distances in mileage calculations; can be true or false.
bordersOpen{Boolean} Indicates whether borders are open for travel.  Default: true
overrideRestrict{Boolean} Indicates whether or not to override truck restrictions.  Default: false
hazMatType{Number} Restricts the route to roads that allow transportation of the selected hazardous material.  Default: 0 (0 - None, 1 - General, 2 - Caustic, 3 - Explosives, 4 - Flammable, 5 - Inhalants, 6 - Radioactive)
routeOptimization{Number} 0 - None, 1 - Optimize All Stops, 2 - Optimize Intermediate Stops.  Default: 0
lang{String} The language.  (ENUS - English United States, ENGB - English Great Britain, DE - German, FR - French, ES - Spanish, IT - Italian)
hubRouting{Boolean} Indicates whether or not to enable hub routing; can be true or false.
trkUnits{Number} Vehicle dimension units; can be English or Metric.  Default: 0 (0 - Indicates that vehicle dimension units should be English, 1 - Indicates that vehicle dimension units should be metric)
trkHeight{Number} The height of the vehicle in feet and inches or meters depending on units.
trkLength{Number} The length of the vehicle in feet and inches or meters depending on units.
trkWidth{Number} The width of the vehicle in feet and inches or meters depending on units.
trkWeight{Number} The weight of the vehicle in pounds or kilograms depending on units.
trkAxles{Number} The number of axles on the vehicle; acceptable values are 2 through 14.  Default: 5
truckConfig{Number} The vehicle style.  Default: 0 (0 - no vehicle style is chosen, 1 - 28’ double trailer, 2 - 40’ straight trailer, 3 - 48’ semitrailer, 4 - 53’ semitrailer)
trkLCV{Boolean} Indicates whether the truck is a multi-trailer or longer combination vehicle.
inclTollData{Boolean} Indicates whether or not reports should calculate toll costs.  Default: true
fuelEconLoad{Number} The fuel efficiency (distance units per fuel units) when loaded.
fuelEconEmpty{Number} The fuel efficiency (distance units per fuel units) when empty.
costPerFuelUnit{Number} The cost per fuel unit of fuel.
costGHG{Number} The cost of greenhouse gas in lbs. per fuel unit.
costMaintLoad{Number} The maintenance cost per distance unit when loaded.
costMaintEmpty{Number} The maintenance cost per distance unit when empty.
costTimeLoad{Number} The time cost per mile/km when loaded.
costTimeEmpty{Number} The time cost per mile/km when empty.
tollCurrency{Number} The toll currency.  Default: 0 (0 - United States dollars, 1 - Canadian dollars)
exchangeRate{Number} The change rate to convert US dollars to Canadian dollars.
tollPlanThe toll discount plan which is a comma-separated list of toll discount programs.  Use All for everything otherwise valid values are (407ETR Transponder,A25 Transponder,BreezeBy,C-Pass,Cruise Card,E-Pass,E-Pass Canada,EXpress Toll,EZ Tag,EZPass,EZPass-NJ,EZPass-WV,FAST LANE,FasTrak,GeauxPass,Good To Go,GO-PASS,I-Pass,I-Zoom,K-TAG,Laredo Trade Tag,LeeWay,MACPASS,NC Quick Pass,NEXPress,Palmetto Pass,Peach Pass,PikePass,Quickpass,Smart Tag,StraitPASS,SunPass,TollTag,TxTag,Wabash Pass)
citeInt{Number} The cite interval to be used when generating a geotunnel report.  The minimum value is 0.1.
region{String} The data region in which the route stops are located.  Default: NA (NA - North America, EU - Europe, OC, SA - South America)

Valid report options include

type{String} Comma-separated list of requested report types.  (Mileage, Directions, Detail, State, CalcMiles, LeastCost, Geotunnel)
format{String} The format of the report returned with the route.  Default: json (json, html) dataVersion {String} Data version.  (‘current’,’PCM18’ through ‘PCM26’)
ALKMaps.Services.getReports({
    coords: [[-75.173297,39.942892],[-74.438942,39.362469]],
    options: {
        vehicleType: 2,
        routingType: 0,
        routeOptimization: 1,
        highwayOnly: false,
        distanceUnits: 0,
        tollCurrency: 0,
        inclTollData:true,
        region: "NA"
    },
    reportOptions: {
        type: "Directions,Mileage",
        format: "json",
        dataVersion: "current"
    },
    success: function(resp){Display Reports}
});

getRoutePath

services.getRoutePath = function (params)

Takes coords objects and route options, return lat/lons for the route path.  Todo

Parameters

inputs{Object} Todo
Todo sample code

addAvoidFavorSet

services.addAvoidFavorSet = function(params)

Add a new avoid/favor set.

Parameters

{ ‘name’:’Unit tests’, // Description of the set ‘tag’:’unitTests’}, // Additional information to categorize or group closures in a set ‘async’: true, ‘success’: function(resp){ }, ‘failure’: function(resp){ } };

Returns

{Number}set Id.

getAvoidFavorSets

services.getAvoidFavorSets = function(params)

Retrieves all AvoidFavorSets, one specific set if the setId is specified.

Parameters

{ ‘setId’: ‘2099’, // -1 to retrieve all.  ‘name’: ‘test’, // To retrieve all AvoidFavor associated with the name, this will be ignored if a set id is passed in.  ‘tag’: ‘unitTest’, // To retrieve all AvoidFavor associated with the tag, this will be ignored if a set id is passed in.  ‘detail’: true, ‘async’: true, ‘success’: function(resp){ }, ‘failure’: function(resp){ } }

Returns

[ { “Links”:[ { “AvoidFavorID”:476583, “AvoidFavorType”:1, “Comment”:”unitTest”, “Geometries”:[ [ [-78.011913,40.711918], [-78.005676,40.714624], [-77.999278,40.717677] ], [ [-78.011913,40.711918], [-78.005676,40.714624], [-77.999278,40.717677] ] ] } ], “Name”:”Random 365690”, “SetID”:12914, “Tag”:”unitTests” } ]

updateAvoidFavorSet

services.updateAvoidFavorSet = function(params)

Update name and tag based on set Id.  If no record is found, the bad request error with message will be returned.

Parameters

{ ‘setId’: ‘12916’, // {String} the existing avoid/favor set ID ‘tag’: ‘unitTests’, // {String} the new tag for the avoid/favor set ‘name’: ‘unitTest again’, // {String} the new name for the avoid/favor set ‘success’: function(resp){ }, ‘failure’: function(resp){ } }

Returns

{ Number } The number of rows affected.

deleteAvoidFavorSet

services.deleteAvoidFavorSet = function(params)

Deletes the AvoidFavor set.

Parameters

{ ‘setId’: ‘12’ // {String} set id.  ‘success’: function(resp){ }, ‘failure’: function(resp){ } }

Returns

{Number} The number of items have been deleted.

addAvoidFavor

services.addAvoidFavor = function(params)

Add a new set with closure.

Parameters

{ ‘setId’: 1, //If a set ID is supplied, the system will try to add closures to the given set.  ‘projection’: ‘EPSG:4326’, // Accepted projection code format ‘region’: ‘NA’, // Map region ‘mapBounds’: new ALKMaps.Bounds( // Map viewport box -78.02197265625, // Longitude - the left bounds of the box 40.68802734375, // Latitude - the bottom bounds of the box -77.97802734375, // Longitude - the right bounds 40.73197265625), // Latitude - the top bounds ‘afPoint’: { ‘type’:’c’, // Supply “c” to request a closure.  At this time, it does not matter because the system will treat all user input as closure.  ‘comment’:’unitTest’, // Description of the closure path ‘point’: // Use this location to generate closure path new ALKMaps.LonLat(-78.000183105469, 40.71745844841)}, ‘async’: true, ‘success’: function(resp){ }, ‘failure’: function(resp){ } };

Returns

[ { “AvoidFavorID”:476583, “AvoidFavorType”:1, “Comment”:”unitTest”, “Geometries”:[ [ [-78.011913,40.711918], [-78.005676,40.714624], [-77.999278,40.717677] ], [ [-78.011913,40.711918], [-78.005676,40.714624], [-77.999278,40.717677] ] ] } ]

deleteAvoidFavor

services.deleteAvoidFavor = function(params)

Deletes a specific AvoidFavors within a set.

Parameters

{ setId : “1”, // {string} The avoid favor set id in which the avoid favor resides. afId : “12” // {string} The avoid favor id to delete.  }

Returns

{Number} The number of rows affected.

services.getCustomPlaces = function (inputs)
Get custom places for a given account.
services.updateCustomPlaceSet = function(inputs)
Update custom place set’s name, and tag for a given set id and tag.
services.deleteCustomPlaceSet = function(inputs)
Delete custom place set for a given id.
services.deleteCustomPlace = function(inputs)
Delete custom place.
services.getCustomCategories = function(inputs)
Get custom categories.
services.addCustomCategory = function(inputs)
Add custom category.
services.updateCustomCategory = function(inputs)
Update custom categories.
services.getReports = function (params)
Takes coords objects and report options, return total time and total distance synchronously.
services.getRoutePath = function (params)
Takes coords objects and route options, return lat/lons for the route path.
services.addAvoidFavorSet = function(params)
Add a new avoid/favor set.
services.getAvoidFavorSets = function(params)
Retrieves all AvoidFavorSets, one specific set if the setId is specified.
services.updateAvoidFavorSet = function(params)
Update name and tag based on set Id.
services.deleteAvoidFavorSet = function(params)
Deletes the AvoidFavor set.
services.addAvoidFavor = function(params)
Add a new set with closure.
services.deleteAvoidFavor = function(params)
Deletes a specific AvoidFavors within a set.
Close