H.service.GeocodingService
Class Summary
Extends: H.service.AbstractRestService
This class encapsulates the Geocoding REST API in a service stub, providing methods to access its resources.
[ For full details, see the Class Details ]
Method Summary
Methods |
---|
This method sends a geocoding request to the Geocoder REST API and calls the |
This method sends a reverse geocoding request to Geocoder REST API and calls the |
This method sends a landmark search request to the Geocoder REST API and calls the |
This method receives configuration parameters from the platform, that can be used by the object implementing the interface. The method must not be invoked directly. |
Class Description
This class encapsulates the Geocoding REST API in a service stub, providing methods to access its resources.
An instance of this class can be retrieved by calling the factory method on a platform instance, H.service.Platform#getGeocodingService.
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);
Constructor Details
H.service.GeocodingService(opt_options)
- Parameters:
-
opt_options
: -
{H.service.GeocodingService.Options=} [optional]
- An object containing configuration options for
GeocodingService
Method Details
geocode (geocodingParams, onResult, onError) : {H.service.JsonpRequestHandle}
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.
- Parameters:
-
geocodingParams
: -
{H.service.ServiceParameters}
- An object containing the 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 JSON-P request
- Returns:
-
{H.service.JsonpRequestHandle}
- A JSON-P request handle
reverseGeocode (reverseGeocodingParams, onResult, onError) : {H.service.JsonpRequestHandle}
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.
- Parameters:
-
reverseGeocodingParams
: -
{H.service.ServiceParameters}
- An object containing 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 JSON-P request
- Returns:
-
{H.service.JsonpRequestHandle}
- A JSON-P request handle
search (searchParams, onResult, onError) : {H.service.JsonpRequestHandle}
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.
- Parameters:
-
searchParams
: -
{H.service.ServiceParameters}
- An object containing 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 JSON-P request
- Returns:
-
{H.service.JsonpRequestHandle}
- A JSON-P request handle
configure (appId, appCode, useHTTPS, useCIT, opt_baseUrl) : {H.service.IConfigurable}
This method receives configuration parameters from the platform, that can be used by the object implementing the interface. The method must not be invoked directly.
Example
// assuming that the configurable object exists and the variable name is "configurable"
var platform = new H.service.Platform({
'app_id': [your app_id],
'app_code': [your app_code],
})
platform.configure(configurable);
- Parameters:
-
appId
: -
{string}
- The application ID to identify the client against the platform (mandatory)
-
appCode
: -
{string}
- The application code to identify the client against the platform (mandatory)
-
useHTTPS
: -
{boolean}
- The indicator whether secure communication is used (
true
), the default isfalse
-
useCIT
: -
{boolean}
- A value indicating whether Customer Integration Testing ("CIT") is used (
true
), the default isfalse
-
opt_baseUrl
: -
{H.service.Url=} [optional]
- The base URL of the platform, the default is
http://api.here.com
. Note that if theuseHTTPS
flag is set totrue
, the URL scheme specified in theopt_baseUrl
is overridden to useHTTPS
.
- Returns:
-
{H.service.IConfigurable}
- An instance of
IConfigurable
reflecting the new configuration