Class: GeocodingService

H.service.GeocodingService

new H.service.GeocodingService (opt_options) Deprecated : since 3.1.14.0

This service is no longer being actively developed. The H.service.SearchService could be used instead.

This class encapsulates the Geocoding REST API in a service stub, providing methods to access its resources.

It's not allowed to call the constructor directly (an IllegalOperationError is thrown). Instead an instance of this Service can be retrieved by calling the factory method H.service.Platform#getGeocodingService on a platform instance.

Name Type Description
opt_options H.service.GeocodingService.Options optional

Configuration options for geocoding service

Throws:
Example
// Assumption: the platform is instantiated
geocoder = platform.getGeocodingService();

var geocodingParams = {
      searchText: '425 W Randolph Street, Chicago'
    },
    onResult = function(result) {
      console.log(result.Response.View[0].Result[0].Location.DisplayPosition);
    },
    onError = function(error) {
       console.log(error);
    };
geocoder.geocode(geocodingParams, onResult, onError);

Extends

Members

H.service.GeocodingService.CONFIG_KEY string staticconstant

The property name to use when specifying options for this service within the H.service.Platform.Options#servicesConfig.

Methods

addEventListener (type, handler, opt_capture, opt_scope) inherited

This method adds a listener for a specific event.

Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it.

Name Type Description
type string

The name of the event

handler function

An event handler function

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object optional

An object defining the scope for the handler function

addOnDisposeCallback (callback, opt_scope) inherited

This method adds a callback which is triggered when the EventTarget object is being disposed.

Name Type Description
callback function

The callback function.

opt_scope Object optional

An optional scope for the callback function

dispatchEvent (evt) inherited

This method dispatches an event on the EventTarget object.

Name Type Description
evt H.util.Event | string

An object representing the event or a string with the event name

dispose () inherited

This method removes listeners from the given object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.

geocode (geocodingParams, onResult, onError)H.util.ICancelable

This method sends a geocoding request to the Geocoder REST API and calls the onResult callback function once the service response becomes available (providing a H.service.ServiceResult object) or the onError callback if a communication error occurs.

Please refer to the Geocoder REST API documentation for information on available parameters and the response object structure.

Name Type Description
geocodingParams H.service.ServiceParameters

Contains service parameters to be sent with the geocoding request.

onResult function(H.service.ServiceResult)

A callback function to be called once the Geocoder REST API provides a response to the request.

onError function(Error)

A callback function to be called if a communication error occurs during the request

Returns:
Type Description
H.util.ICancelable A request handle

This method returns the configured service URL.

Returns:
Type Description
H.service.Url

removeEventListener (type, handler, opt_capture, opt_scope) inherited

This method removes a previously added listener from the EventTarget instance.

Name Type Description
type string

The name of the event

handler function

A previously added event handler

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object optional

An object defining the scope for the handler function

reverseGeocode (reverseGeocodingParams, onResult, onError)H.util.ICancelable

This method sends a reverse geocoding request to Geocoder REST API and calls the onResult callback function once the service response becomes available (providing a H.service.ServiceResult object) or the onError callback if a communication error occurs.

Please refer to the Geocoder REST API documentation for information on available parameters and the response object structure.

Name Type Description
reverseGeocodingParams H.service.ServiceParameters

Contains the service parameters to be sent with the reverse geocoding request

onResult function(H.service.ServiceResult)

A callback function to be called once the Geocoder REST API provides a response to the request

onError function(Error)

A callback function to be called if a communication error occurs during the request

Returns:
Type Description
H.util.ICancelable A request handle

This method sends a landmark search request to the Geocoder REST API and calls the onResult callback function once the service response becomes available (providing a H.service.ServiceResult object) or the onError callback if a communication error occurs.

Please refer to the Geocoder REST API documentation for information on available parameters and the response object structure.

Name Type Description
searchParams H.service.ServiceParameters

Contains the service parameters to be sent with the landmark search request

onResult function(H.service.ServiceResult)

A callback function to be called once the Geocoder REST API provides a response to the request

onError function(Error)

A callback function to be called if a communication error occurs during the request

Returns:
Type Description
H.util.ICancelable A request handle

Type Definitions

H.service.GeocodingService.Options Object

This type encapsulates configuration (initialization) options for an instance of GeocodingService.

Properties:
Name Type Argument Description
baseUrl H.service.Url <optional>

The base URL of the Geocoding service. If supplied, it overrides all defaults (either coming from platform or service internals) including authentication params

subDomain string <optional>

The subdomain of the Geocoding service relative to the platform's base URL, the default is "geocoder"

reverseSubDomain string <optional>

The subdomain of the reverse Geocoding service relative to the platform's base URL, the default is "reverse"

path string <optional>

The path of the Geocoding service, the default is "6.2"

headers Object.<string, *> <optional>

A map of HTTP headers to be sent with each request made by the service