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.
singleSearchThis function performs single search.
singleSearchGetGets states, countries and more.
singleSearchGetRegionsReturns regions are currently supported.
singleSearchGetCountryTypesReturns country abbreviations supported.

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.
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).
async{Boolean} Send service request asynchronously or not.
success{Function} Function handles success asynchronous service response.
failure{Function} Function handles failure asynchronous 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.
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).
searchString{String} Allows searching of [zip] [city,] [state][; street] or [splc] all on one line.  Individual street/city/state/postcode/splc fields will be ignored when this is used.  If street address is supplied it requires a zip and/or city and must be prefaced by a semicolon.  For example, “08540 Princeton, NJ;” or “457 N Harrison St” or “08540” or “Princeton”

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};
Alternatively, you can specify search of [zip] [city,] [state][; street] or [splc] all on one line. For example:
var inputs = {"address": {"searchString": "08540 Princeton, NJ;"}, "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", "region":"NA", "dataset":"Current"},
   "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.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”:[]}]

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, “dataset”:dataset}, “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 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.
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).

Returns

{ALKMaps.LonLat}

singleSearch

ALKMaps.Geocoder.singleSearch = function(inputs)

This function performs single search.

Parameters

inputs{Object}

Valid properties for inputs parameter

query{String} Your search query.  Required.
maxResults{Number} Maximum returned results.  Between 0 and 100
currentLonLat{ALKMaps.LonLat} Current longitude and latitude values in degrees.
excludedSearchTypes{String} Comma-separated list of types to exclude from the search.
poiCategories{String} Comma-separated list of poi category names by which you want to filter all POI results.
countries{String} Comma-separated list of country abbreviations by which you want to filter all results.  Defaults to ISO format.
countryType{String} ISO, FIPS, GENC2, GENC3
states{String} Comma-separated list of state abbreviations by which you want to filter all results.
region{String} NA, EU, WW.  To get supported regions, you can call ALKMaps.Geocoder.singleSearchGetRegions() method.
async{Boolean} Open an asynchronous request.  Default is true.
success{Function} To overwrite default handler, supply custom method here.
failure{Function} To overwrite default handler, supply custom method here.

singleSearchGet

ALKMaps.Geocoder.singleSearchGet = function(inputs)

Gets states, countries and more.

Parameters

inputs{Object}

Valid properties for inputs parameters

query{String} Accept states, countries, types, poiCategories or resultTypes as string
region{String} Accept NA, EU and WW.

Returns the list of search’s acceptable states for filtering if query string is “states”.  Returns the list of search’s acceptable countries for filtering if query string is “countries” Returns the list of search’s known interp types if query string is “types”.  Returns the list of search’s acceptable POI categories for filtering if query string is “poiCategories”.  Returns the list of search’s known result types with their integer to string mapping if query string is “resultTypes”.

singleSearchGetRegions

ALKMaps.Geocoder.singleSearchGetRegions = function()

Returns regions are currently supported.

singleSearchGetCountryTypes

ALKMaps.Geocoder.singleSearchGetCountryTypes = function()

Returns country abbreviations supported.

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.
ALKMaps.Geocoder.singleSearch = function(inputs)
This function performs single search.
ALKMaps.Geocoder.singleSearchGet = function(inputs)
Gets states, countries and more.
ALKMaps.Geocoder.singleSearchGetRegions = function()
Returns regions are currently supported.
ALKMaps.Geocoder.singleSearchGetCountryTypes = function()
Returns country abbreviations supported.
This class represents a longitude and latitude pair
Close