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.

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.

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

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 is false
useCIT:
{boolean}
 
A value indicating whether Customer Integration Testing ("CIT") is used (true), the default is false
opt_baseUrl:
{H.service.Url=} [optional]
 
The base URL of the platform, the default is http://api.here.com. Note that if the useHTTPS flag is set to true, the URL scheme specified in the opt_baseUrl is overridden to use HTTPS.
Returns:
 
{H.service.IConfigurable}
An instance of IConfigurable reflecting the new configuration