Maps API for JavaScript

China specific
Maps API for JavaScript Developer's Guide

H.service.RoutingService

Class Summary

Extends: H.service.AbstractRestService

This class encapsulates the Routing REST API as a service stub. An instance of this class can be obtained by calling the factory method on a platform instance, H.service.Platform#getRoutingService.

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

calculateRoute (calculateRouteParams, onResult, onError)

This method sends a "calculateroute" request to the Routing 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 occurred.

calculateIsoline (calculateRouteParams, onResult, onError)

This method sends a "calculateisoline" request to the Routing 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 occurred.

Class Description

This class encapsulates the Routing REST API as a service stub. An instance of this class can be obtained by calling the factory method on a platform instance, H.service.Platform#getRoutingService.

Example

// Assumption: the platform is instantiated
router = platform.getRoutingService();

var calculateRouteParams = {
    'waypoint0': 'geo!52.5,13.4',
    'waypoint1': 'geo!52.5,13.45',
    'mode': 'fastest;car;traffic:disabled'
  },
  onResult = function(result) {
    console.log(result.response.route[0]);
  },
  onError = function(error) {
     console.log(error);
  };
router.calculateRoute(calculateRouteParams, onResult, onError);

Constructor Details

H.service.RoutingService(opt_options)

Parameters:
 
opt_options:
{H.service.RoutingService.Options=} [optional]
 
An object containing initialization options

Method Details

calculateRoute (calculateRouteParams, onResult, onError)

This method sends a "calculateroute" request to the Routing 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 occurred.

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

Parameters:
 
calculateRouteParams:
{H.service.ServiceParameters}
 
An object containing the service parameters to be sent with the routing request.
onResult:
{function(H.service.ServiceResult)}
 
A callback function to be called once the Routing 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

calculateIsoline (calculateRouteParams, onResult, onError)

This method sends a "calculateisoline" request to the Routing 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 occurred.

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

Parameters:
 
calculateRouteParams:
{H.service.ServiceParameters}
 
An object containing the service parameters to be sent with the routing request.
onResult:
{function(H.service.ServiceResult)}
 
A callback function to be called once the Routing 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