A utility class can be used to consume ALK mapping, geocoding, and routing services.
ALKMaps. | A utility class can be used to consume ALK mapping, geocoding, and routing services. |
Functions | |
reverseGeocode | This function takes latitude and longitude, returns address object synchronously or asynchronously. |
geocode | This function takes address object, returns address arrays with longitudes and latitudes. |
simpleGeocode | This function takes address object, returns address arrays with longitudes and latitudes. |
ALKMaps.Geocoder.reverseGeocode = function ( inputs )
This function takes latitude and longitude, returns address object synchronously or asynchronously.
inputs | {Object} Accept {“lonLat”:ALKMaps.LonLat, “region”:String, “async”:Boolean, “success”: cbfunction, “failure”: cbfunction} |
lonLat | {ALKMaps.LonLat} 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. |
async | {Boolean} Send service request asynchronously or not. |
success | {Function} Function handles success asynchronouse service response. |
failure | {Function} Function handles failure asynchronouse service response. |
{Array of Address Object}
Call reverseGeocode function synchronously
var lonlat = new ALKMaps.LonLat(-122.31693, 47.60784); var d = ALKMaps.Geocoder.reverseGeocode({"lonLat":lonlat, "async":false});
Call reverseGeocode function asynchronously
var inputs = { "lonLat":new ALKMaps.LonLat(-122.31693, 47.60784), "async":true, "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.Geocoder.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 }]
ALKMaps.Geocoder.geocode = function ( inputs )
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.
inputs | {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. |
{Array of Address Object}
Call geocode function synchronously
var inputs = {"address":{"addr":"1048 Spring Street", "city":"Seattle", "state":"WA", "zip":"98104"}, "async":false}; var address = ALKMaps.Geocoder.geocode(inputs);
Call geocode function asynchronously
var inputs = { "address":{"addr":"1048 Spring Street", "city":"Seattle", "state":"WA", "zip":"98104"}, "async":true, "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.Geocoder.reverseGeocode(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”:[]}]
ALKMaps.Geocoder.simpleGeocode = function ( inputs )
This function takes address object, returns address arrays with longitudes and latitudes.
inputs | {Object} Accept {“address”: {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode, “region”:region}, “async”:Boolean, “success”:cbfunction, “failure”:cbfunction} |
address | {Object} Accept JSON structure {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode, “region”:region} |
async | {Boolean} Send service request asynchronously or not. |
success | {Function} Function handles success asynchronouse service response. |
failure | {Function} Function handles failure asynchronouse 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. |
{ALKMaps.LonLat}
This function takes latitude and longitude, returns address object synchronously or asynchronously.
ALKMaps.Geocoder.reverseGeocode = function ( inputs )
This function takes address object, returns address arrays with longitudes and latitudes.
ALKMaps.Geocoder.geocode = function ( inputs )
This function takes address object, returns address arrays with longitudes and latitudes.
ALKMaps.Geocoder.simpleGeocode = function ( inputs )