ALKMaps.Geocoder

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

Summary
ALKMaps.GeocoderA utility class can be used to consume ALK mapping, geocoding, and routing services.
Functions
reverseGeocodeThis function takes latitude and longitude, returns address object synchronously or asynchronously.
geocodeThis function takes address object, returns address arrays with longitudes and latitudes.
simpleGeocodeThis function takes address object, returns address arrays with longitudes and latitudes.

Functions

reverseGeocode

ALKMaps.Geocoder.reverseGeocode = function (inputs)

This function takes latitude and longitude, returns address object synchronously or asynchronously.

Parameters

inputs{Object} Accept {“lonLat”:ALKMaps.LonLat, “region”:String, “async”:Boolean, “success”: cbfunction, “failure”: cbfunction}

Valid properties for inputs parameter

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.

Returns

{Array of Address Object}

Examples

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 }]

geocode

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.

Parameters

inputs{Object} Accepts {“address”: {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode, “region”:region}, “listSize”:number, “async”:Boolean, “success”:cbfunction, “failure”:cbfunction}

Valid properties for inputs parameter

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.

Properties of address type

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.

Returns

{Array of Address Object}

Examples

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”:[]}]

simpleGeocode

ALKMaps.Geocoder.simpleGeocode = function (inputs)

This function takes address object, returns address arrays with longitudes and latitudes.

Parameters

inputs{Object} Accept {“address”: {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode, “region”:region}, “async”:Boolean, “success”:cbfunction, “failure”:cbfunction}

Valid properties for inputs parameter

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.

Properties of address type

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.

Returns

{ALKMaps.LonLat}

ALKMaps.Geocoder.reverseGeocode = function (inputs)
This function takes latitude and longitude, returns address object synchronously or asynchronously.
ALKMaps.Geocoder.geocode = function (inputs)
This function takes address object, returns address arrays with longitudes and latitudes.
ALKMaps.Geocoder.simpleGeocode = function (inputs)
This function takes address object, returns address arrays with longitudes and latitudes.
Close