Maps API for JavaScript Developer's Guide

H.service.RoutingService

Class Summary

This class encapsulates the Routing REST API as a service stub.

[ For full details, see the Class Details ]

Property Summary

Table 1. Properties
Properties

static CONFIG_KEY : {string}

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

Method Summary

Table 2. 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.

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#getRoutingService on a platform instance.

Example

// Assumption: the platform is instantiated
var router = platform.getRoutingService();
router.calculateRoute({
  'waypoint0': 'geo!52.5,13.4',
  'waypoint1': 'geo!52.5,13.45',
  'mode': 'fastest;car;traffic:disabled'
}, function(result) {
  console.log(result.response.route[0]);
}, function(error) {
   console.error(error);
});

Constructor Details

H.service.RoutingService(opt_options)

Parameters:
 
opt_options:
{H.service.RoutingService.Options=} [optional]
 
Configuration options for routing service

Property Details

static CONFIG_KEY: {string}

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

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}
 
Contains 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 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 request