Click or drag to resize

Telogis.GeoBase.GeoCoder

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
GeoCoder Namespace

Contains functions for sending forward- and reverse-geocoding requests to the GeoStream server. Note that you can enable the GeocodingLogging option to monitor GeoStream geocoding performance. For more information see web.config

Classes
NameDescription
GeoCoder.AddressRepresents the physical address returned by reverse geocoding.
GeoCoder.GeoCodeAddressRepresents a LatLon and a physical address, returned as the result of GeoCoding.
GeoCoder.GeoCodeFullA composite object that represents the result of a reverse geocoding call.
GeoCoder.HMMGeoCodeAddressRepresents a LatLon and a physical address, returned as the result of GeoCoding.
GeoCoder.UnknownGeoCodeAddressRepresents a generic (or 'unknown') LatLon and a physical address. It contains no more than a street address, city, zip code and region.
GeoCoder.USGeoCodeAddressRepresents a LatLon and a physical address, returned as the result of GeoCoding in the United States.
Functions
NameDescription
geoCode (String address, String country, Function callback, Function errorCallback, Object server)

Converts an address to a set of latlon co-ordinates.

JavaScript
var address = '20 Enterprise, Aliso Viejo, California';
var country = 'USA';

function myTestFunction() {
    GeoCoder.geoCode (address, country, function (callback) {

        // Callback function begins
        if (callback.length > 0) {
            var loc = callback[0].getLocation();
            alert ('Found ' + callback[0] + ' at LatLon ' + loc);
        } else {
            alert ('No matching addresses were found.');
        }
    }, errorCallback ('Geocode'));
};

// A compact way of generating error callbacks.
// Test by changing 'country' var to an uninstalled region.
var errorCallback = function (context) {
    return function (error) {
        alert (context + ' failed (' + error.name + '): ' + error.message);
    };
};
Arguments
  • address (String) - The address you are wishing to find (can include any combination of street number, name, city, region, postal code).

  • country (String) - The country that the address is located in.

  • callback (Function) - The arbitrary callback to execute once the geocoding request returns.

    Arguments
  • (Optional) errorCallback (Function) - A callback to execute if an error or timeout occurs when performing the geocode. Returns the error or timeout that occurred when performing the query. Defaults to null.

    Arguments
    • error (Telogis.Errors.GeoBaseError) - An exception describing the problem that was encountered by the geocoder.

  • server (Object) - An optional object that contains server.url (The address of the GeoStream server as a string) and server.authToken (The GeoStream authentication token to be used for requesting tiles) to be used for this request.

geoCodeExtended (String address, String city, String region, Number postalCode, String country, Function callback, Function errorCallback, Object server)

Converts an [extended] address to a set of latlon co-ordinates.

JavaScript
var address = '20 Enterprise';
var city = 'Aliso Viejo';
var region = 'California'; // Also accepts 'CA'
var postalcode = '92656';
var country = 'USA';

function myTestFunction() {
    GeoCoder.geoCodeExtended (address, city, region, postalcode, country, function (callback) {

        // Callback function begins
        if (callback.length > 0) {
            var loc = callback[0].getLocation();
            alert ('Found ' + callback[0] + ' at LatLon ' + loc);
        } else {
            alert ('No matching addresses were found.');
        }
    }, errorCallback('Geocode'));
};

// A compact way of generating error callbacks.
// Test by changing 'country' var to an uninstalled region.
var errorCallback = function (context) {
    return function (error) {
        alert (context + ' failed (' + error.name + '): ' + error.message);
    };
};
Arguments
  • address (String) - The street number and name that you're wanting to find the address for.

  • city (String) - The city that the address is located in.

  • region (String) - The region that the address is located in (two character state abbreviations work here).

  • postalCode (Number) - The postal code that the address is located in.

  • country (String) - The country that the address is located in.

  • callback (Function) - The callback that is executed once the geocoding request returns.

    Arguments
  • (Optional) errorCallback (Function) - A callback to execute if an error or timeout occurs when performing the geocode. Defaults to null.

    Arguments
    • error (Telogis.Errors.GeoBaseError) - An exception describing the problem that was encountered by the geocoder.

  • server (Object) - An optional object that contains server.url and server.authToken to be used for this request

geoCodeStructured (Number number, String prefix, String bf_type, String name, String af_type, String suffix, String city, String region, String postalCode, String country, Function callback, Function errorCallback, Object server)

Converts a [structured] address to a set of latlon co-ordinates.

JavaScript
var s_number = 17;
var s_prefix = 'West';
var s_typebefore = '';
var s_name = 'Ryley';
var s_typeafter = 'Court';
var s_suffix = '';
var s_city = 'Aliso Viejo';
var s_region = 'California'; // Also accepts 'CA'
var s_postalcode = '92656';
var s_country = 'USA';

function myTestFunction() {
    Telogis.GeoBase.GeoCoder.geoCodeStructured (s_number, s_prefix, s_typebefore, s_name,
    s_typeafter, s_suffix, s_city, s_region, s_postalcode, s_country, function (callback) {
        // Callback function begins
        if (callback.length > 0) {
            var loc = callback[0].getLocation();
            alert ('Found ' + callback[0] + ' at LatLon ' + loc);
        } else {
            alert ('No matching addresses were found.');
        }
    }, errorCallback('Geocode'));
};

// A compact way of generating error callbacks.
// Test by changing 'country' var to an uninstalled region.
var errorCallback = function (context) {
    return function (error) {
        alert (context + ' operation failed (' + error.name + '): ' + error.message);
    };
};
Arguments
  • number (Number) - The street number that you're wanting to find the address for.

  • prefix (String) - The street prefix that you're wanting to find the address for.

  • bf_type (String) - The street type before that you're wanting to find the address for. For example "rue", "chemin"

  • name (String) - The street name that you're wanting to find the address for.

  • af_type (String) - The street type after that you're wanting to find the address for. For example "street", "avenue"

  • suffix (String) - The street suffix that you're wanting to find the address for.

  • city (String) - The city that the address is located in.

  • region (String) - The region that the address is located in (two character state abbreviations work here).

  • postalCode (String) - The postal code that the address is located in.

  • country (String) - The country that the address is located in.

  • callback (Function) - The callback that is executed once the geocoding request returns.

    Arguments
  • (Optional) errorCallback (Function) - A callback to execute if an error or timeout occurs when performing the geocode. Defaults to null.

    Arguments
    • error (Telogis.Errors.GeoBaseError) - An exception describing the problem that was encountered by the geocoder.

  • server (Object) - An optional object that contains server.url and server.authToken to be used for this request

reverseGeoCode (LatLon loc, Function callback, Function errorCallback, Object server)

Converts a set of latlon co-ordinates to a physical address.

JavaScript
// LatLon to reverse geocode
var s_loc =  new Telogis.GeoBase.LatLon(33.584444,-117.731874);

function myTestFunction() {
    Telogis.GeoBase.GeoCoder.reverseGeoCode (s_loc, function (callback) {
        // Callback function begins
        if (callback) {
            alert ('Found ' + callback + ' at LatLon ' + s_loc);
        } else {
            alert ('No matching addresses were found at ' + s_loc);
        }
    }, errorCallback('Reverse Geocode'));
};

// A compact way of generating error callbacks.
var errorCallback = function (context) {
    return function (error) {
        alert (context + ' operation failed (' + error.name + '): ' + error.message);
    };
};
Arguments
  • loc (LatLon) - The location that you wish to find the address for.

  • callback (Function) - A function that is called when the result object is returned.

    Arguments
  • (Optional) errorCallback (Function) - A callback to execute if an error or timeout occurs when performing the reverse-geocode. Defaults to null.

    Arguments
    • error (Telogis.Errors.GeoBaseError) - An exception describing the problem that was encountered by the geocoder.

  • server (Object) - An optional object that contains server.url and server.authToken to be used for this request

reverseGeoCodeFull (LatLon loc, Function callback, Function errorCallback, Object server)

Converts a latlon to a physical address and returns extended information.

JavaScript
// LatLon to reverse geocode
var s_loc =  new Telogis.GeoBase.LatLon(33.584444,-117.731874);

function myTestFunction() {
    Telogis.GeoBase.GeoCoder.reverseGeoCodeFull (s_loc, function (callback) {
        // Callback function begins
        if (callback) {
            alert ('Found ' + callback + ' at LatLon ' + s_loc);
        } else {
            alert ('No matching addresses were found at ' + s_loc);
        }
    }, errorCallback('Full Reverse Geocode'));
};

// A compact way of generating error callbacks.
var errorCallback = function (context) {
    return function (error) {
        alert (context + ' operation failed (' + error.name + '): ' + error.message);
    };
};
Arguments
  • loc (LatLon) - The location that you're wanting to find the address for.

  • callback (Function) - A function that is called when the result object is returned.

    Arguments
  • (Optional) errorCallback (Function) - A callback to execute if an error or timeout occurs when performing the reverse-geocode. Defaults to null.

    Arguments
    • error (Telogis.Errors.GeoBaseError) - An exception describing the problem that was encountered by the geocoder.

  • server (Object) - An optional object that contains server.url and server.authToken to be used for this request