The ALKMaps services class
Services | The ALKMaps services class |
Functions | |
geocode | This function takes address object, returns address arrays with longitudes and latitudes. |
reverseGeocode | This function takes latitude and longitude, returns address object synchronously or asynchronously. |
getRoutePath | Takes coords objects and route options, return lat/lons for the route path. |
getReports | Takes coords objects and report options, return total time and total distance synchronously. |
getAttribution | Retrieves the neccessary attribution for a given layer based on the layer’s type and its settings. |
services.geocode = function( params )
This function takes address object, returns address arrays with longitudes and latitudes. If the geocoding service finds multiple results that match the address object, by default, one result is returned. To receive multiple results set the optional listSize property to the desired amount.
params | {Object} Accepts {“address”: {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode, “region”:region}, “listSize”:number, “async”:Boolean, “success”:cbfunction, “failure”:cbfunction} |
address | {Object} Accepts {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode} |
listSize | {Number} Optional. Maximum number of results to be returned. |
async | {Boolean} Send service request asynchronously or not. |
success | {Function} Function handles success asynchronous service response. |
failure | {Function} Function handles failure asynchronous service response. |
addr | {String} Street address |
city | {String} City name |
state | {String} The state (or country) abbreviation, for example, AZ for Arizona or NSW for New South Wales. |
zip | {String} The zip or postal code. |
region | {String} The data region in which the address or coordinates lie. Valid values are NA, EU, OC and SA. |
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). |
{Array of Address Object}
var inputs = { "address":{"addr":"1048 Spring Street", "city":"Seattle", "state":"WA", "zip":"98104"}, "success":function(response){ var responseText = response.responseText; // Todo: Convert response text into Json object. }, "failure":function(response){ alert(response.status + '\n' + response.statusText + '\n ' + response.responseText); } }; ALKMaps.Services.geocode(inputs);
Returned result should look like the following - [{“Address”:{“StreetAddress”:”1048 Spring Street”,”City”:”Seattle”,”State”:”WA”,”Zip”:”98104”,”County”:”King”,”Country”:null,”Region”:0,”PlaceName”:null,”SPLC”:null,”CountryPostalFilter”:0,”Label”:null},”Coords”:{“Lat”:”47.609813”,”Lon”:”-122.32636”},”Errors”:[]}]
services.reverseGeocode = function( params )
This function takes latitude and longitude, returns address object synchronously or asynchronously.
params | {Object} |
latLng | {Leaflet.latLng} The place with longitude and latitude values |
region | {String} The data region in which the address or coordinates lie. Valid values are NA, EU, OC and SA. |
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). |
success | {Function} Function handles success asynchronouse service response. |
failure | {Function} Function handles failure asynchronouse service response. |
var inputs = { "lonLat":new ALKMaps.LonLat(-122.31693, 47.60784), "success":function(response){ var responseText = response.responseText; // Todo: Convert response text into Json object. }, "failure":function(response){ alert(response.status + '\n' + response.statusText + '\n ' + response.responseText); } }; ALKMaps.Services.reverseGeocode(inputs);
Returned result should look like the following - [{“Address”:{ “StreetAddress”:”665 12th Avenue”, “City”:”Seattle”, “State”:”WA”, “Zip”:”98122”, “County”:”King”, “Country”:null, “Region”:0, “PlaceName”:””, “SPLC”:null, “CountryPostalFilter”:0, “Label”:null }, “Coords”:{ “Lat”:”47.60784”, “Lon”:”-122.31693” }, “Errors”:null }]
services.getRoutePath = function( params )
Takes coords objects and route options, return lat/lons for the route path.
params | {Object} |
stops | {String} “lon,lat;...;lon,lat” |
options | {Object} |
success | {Function} Function handles success asynchronous service response. |
failure | {Function} Function handles failure asynchronous service response. |
{ stops: '-75.339368,40.11442;-74.911539,40.159933;-74.885531,39.993483;-75.191123,39.802326', options: { 'vehicleType': 'Truck', 'routingType': 'Practical', 'routeOptimization': 1, 'highwayOnly': false, 'distanceUnits': 'Miles', 'tollDiscourage': true } }
// responseText looks like: { "type":"Feature", "geometry":{ "type":"MultiLineString", "coordinates":[ [[-75.339368,40.11442], ..., [-75.339308,40.114511]], [[-75.191123,39.802326], ..., [-75.191301,39.802518]], [[-74.911705,40.160123], ..., [-74.911539,40.159933]] ] } }
services.getReports = function( params )
Takes coords objects and report options, return total time and total distance synchronously.
params | {Object} |
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. |
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) |
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 | {String} or {Number} The height of the vehicle in feet and inches or meters depending on units. |
trkLength | {String} or {Number} The length of the vehicle in feet and inches or meters depending on units. |
trkWidth | {String} or {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. |
tollPlan | The 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) |
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) |
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’) |
estimatedTimeOpts | {String} Estimated time options, format Depart(Arrive)|[DayOfWeek][SpecificDateTime]|[TimeOfDay], ex: Depart|Monday|18:30 to depart given day of week and time of day; or Arrive|2014-03-04T08:15:30-05:00 to arrive at specific date/time, or Arrive or Depart to arrive or depart with system time. |
breakInterval | {Number} The elapsed time of the trip before a break will be taken. The format is in decimal hours, ex: 3.5 for 3 hours 30 minutes. |
breakLength | {Number} The amount of time a break will last. The format is in decimal hours, ex: 0.5 for 30 minutes. |
borderWait | {Number} The additional amount of time at the border to the overall trip. The format is in decimal hours. |
remHrsOfSvc | {Number} The remaing hours of service at the start of the trip before the driver needs to take a break. The format is in decimal hours. |
useTraffic | {Boolean} Indicates whether or not use traffic when calculating trip transit times. |
L.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} });
services.getAttribution = function( params )
Retrieves the neccessary attribution for a given layer based on the layer’s type and its settings.
layerClass | {<L.ALKMaps.Layer>} layer class. |
style | {String} Style of base layer tiles. |
imgOption | {String} Used specify if instance of base layer contains map tiles or transparent overlay. “Foreground” or “Background”. |
region | {String/Number} Data region of the given layer. |
var attribution = L.ALKMaps.Services.getAttribution( { layerClass: L.ALKMaps.Layer.Tile, region: "NA", style: "satellite", imgOption: "Foreground" } );
This function takes address object, returns address arrays with longitudes and latitudes.
services.geocode = function( params )
This function takes latitude and longitude, returns address object synchronously or asynchronously.
services.reverseGeocode = function( params )
Takes coords objects and route options, return lat/lons for the route path.
services.getRoutePath = function( params )
Takes coords objects and report options, return total time and total distance synchronously.
services.getReports = function( params )
Retrieves the neccessary attribution for a given layer based on the layer’s type and its settings.
services.getAttribution = function( params )