Maps API for JavaScript

China specific
Maps API for JavaScript Developer's Guide

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

Table 1. Methods
Methods

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.

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.

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.

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

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