Guidesv3.2 API Referencev3.1 API Reference

Class: RoutingService8

Class: RoutingService8

Class: RoutingService8

H.service.RoutingService8

new H.service.RoutingService8 (regionCode, opt_options)

This class encapsulates the Routing API v8 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.

Name Type Description
regionCode string

The region code to use for the Service's default configuration.

opt_options H.service.Options optional

Configuration options for routing service

Throws:
Example
// Assumption: the platform is instantiated
let router = platform.getRoutingService();
router.calculateRoute({
  'origin': '48.86,2.31',
  'destination': '48.86,2.35',
  // defines multiple waypoints
  'via': new H.service.Url.MultiValueQueryParameter(['48.8664,2.3234', '48.8703,2.3499']),
  // returns route shape as a polyline in response
  'return': 'polyline',
  'transportMode': 'car'
}, (result) => {
  const sections = result.routes[0].sections;
  const lineStrings = [];
  sections.forEach((section) => {
    // convert Flexible Polyline encoded string to geometry
    lineStrings.push(H.geo.LineString.fromFlexiblePolyline(section.polyline));
  });
  const multiLineString = new H.geo.MultiLineString(lineStrings);
  const bounds = multiLineString.getBoundingBox();
  // render route on the map
  map.addObject(new H.map.Polyline(multiLineString, {style: {lineWidth: 5}}));
  // zoom to polyline
  map.getViewModel().setLookAtData({bounds});
}, console.error);

Extends

Members

H.service.RoutingService8.CONFIG_KEY string staticconstant

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

Methods

addEventListener (type, handler, opt_capture, opt_scope) inherited

This method adds a listener for a specific event.

Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it.

Name Type Description
type string

The name of the event

handler function

An event handler function

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object optional

An object defining the scope for the handler function

addOnDisposeCallback (callback, opt_scope) inherited

This method adds a callback which is triggered when the EventTarget object is being disposed.

Name Type Description
callback function

The callback function.

opt_scope Object optional

An optional scope for the callback function

calculateIsoline (params, onResult, onError)H.util.ICancelable

This method sends a "Calculate Isoline" GET request to the HERE Isoline Routing API v8 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 HERE Isoline Routing API v8 documentation for information on available parameters and the response object structure.

Name Type Description
params H.service.ServiceParameters

Contains service parameters to be sent with the request.

onResult function(H.service.ServiceResult)

A callback function to be called once the API provides a response to the request.

onError function(Error)

A callback function to be called if a communication error occurs during the request.

Returns:
Type Description
H.util.ICancelable a handle that allows to cancel the request.
Example
let routingParams = {
 'routingMode': 'fast',
 'transportMode': 'car',
 'origin':'52.5,13.4',
 'range[type]': 'time',
 'range[values]': '900',
};

// Define a callback function to process the routing response
let onResult = function(result) {
  if (result.isolines.length) {
    result.isolines[0].polygons.forEach((polygon) => {
        // Create a line string to use as a point source for the isoline
        const lineString = H.geo.LineString.fromFlexiblePolyline(polygon.outer);

        // Create a polygon and a marker representing the isoline
        const isolinePolygon = new H.map.Polygon(new H.geo.Polygon(lineString), {
          style: { strokeColor: 'blue', lineWidth: 3 }
        });

        // Create a marker for the start point
        const isolineCenter = new H.map.Marker(result.departure.place.location);

        // Add the polygon and marker to the map
        map.addObjects([isolinePolygon, isolineCenter]);

        // Center and zoom the map so that the whole isoline polygon is
        // in the viewport
        map.getViewModel().setLookAtData({bounds: isolinePolygon.getBoundingBox()});
    });
  }
};

// Assumption: the platform is instantiated.
// Get an instance of the routing service
let router = platform.getRoutingService();

// Call the Isoline Routing API to calculate an isoline
router.calculateIsoline(
  routingParams,
  onResult,
  console.error
);

calculateRoute (params, onResult, onError)H.util.ICancelable

This method sends a GET request to the Routing API v8 to calculate a route 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 API v8 documentation for information on available parameters and the response object structure.

Name Type Description
params H.service.ServiceParameters

Contains service parameters to be sent with the request.

onResult function(H.service.ServiceResult)

A callback function to be called once the API provides a response to the request.

onError function(Error)

A callback function to be called if a communication error occurs during the request.

Returns:
Type Description
H.util.ICancelable a handle that allows to cancel the request.

dispatchEvent (evt) inherited

This method dispatches an event on the EventTarget object.

Name Type Description
evt H.util.Event | string

An object representing the event or a string with the event name

dispose () inherited

This method removes listeners from the given object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.

getRouteByHandle (routeHandle, params, onResult, onError)H.util.ICancelable

This method sends a GET request to the Routing API v8. It decodes and returns a route from a previously calculated route handle.

Refer to Route handle Dev Guide for additional info.

It calls 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 API v8 documentation for information on available parameters and the response object structure.

Name Type Description
routeHandle string

The handle of the previously calculated route.

params H.service.ServiceParameters

Contains service parameters to be sent with the request.

onResult function(H.service.ServiceResult)

A callback function to be called once the API provides a response to the request.

onError function(Error)

A callback function to be called if a communication error occurs during the request.

Returns:
Type Description
H.util.ICancelable a handle that allows to cancel the request.

This method returns the configured service URL.

Returns:
Type Description
H.service.Url

postCalculateIsoline (params, body, onResult, onError)H.util.ICancelable

This method sends a "Calculate Isoline" POST request to the HERE Isoline Routing API v8.

It 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 HERE Isoline Routing API v8 documentation for information on available parameters and the response object structure.

Name Type Description
params H.service.ServiceParameters

Contains service parameters to be sent with the request.

body H.service.ServiceParameters

Contains the request body to be sent with the request.

onResult function(H.service.ServiceResult)

A callback function to be called once the API provides a response to the request.

onError function(Error)

A callback function to be called if a communication error occurs during the request.

Returns:
Type Description
H.util.ICancelable a handle that allows to cancel the request.

postCalculateRoute (params, body, onResult, onError)H.util.ICancelable

This method sends a POST request to the Routing API v8 to calculate a route.

It 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 API v8 documentation for information on available parameters and the response object structure.

Name Type Description
params H.service.ServiceParameters

Contains service parameters to be sent with the request.

body H.service.ServiceParameters

Contains the request body to be sent with the request.

onResult function(H.service.ServiceResult)

A callback function to be called once the API provides a response to the request.

onError function(Error)

A callback function to be called if a communication error occurs during the request.

Returns:
Type Description
H.util.ICancelable a handle that allows to cancel the request.

postGetRouteByHandle (params, body, onResult, onError)H.util.ICancelable

This method sends a POST request to the Routing API v8. It decodes and returns a route from a previously calculated route handle.

Refer to Route handle Dev Guide for additional info.

It 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 API v8 documentation for information on available parameters and the response object structure.

Name Type Description
params H.service.ServiceParameters

Contains service parameters to be sent with the request.

body H.service.ServiceParameters

Contains the request body to be sent with the request.

onResult function(H.service.ServiceResult)

A callback function to be called once the API provides a response to the request.

onError function(Error)

A callback function to be called if a communication error occurs during the request.

Returns:
Type Description
H.util.ICancelable a handle that allows to cancel the request.

postImportRouteFromTracePoints (params, body, onResult, onError)H.util.ICancelable

This method sends an "Calculate a route from a sequence of trace points" POST request to the Routing API v8.

It 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 HERE Routing API v8 documentation for information on available parameters and the response object structure.

Additionally refer to Import a route from traces

Name Type Description
params H.service.ServiceParameters

Contains service parameters to be sent with the request.

body H.service.ServiceParameters

Contains the request body to be sent with the request.

onResult function(H.service.ServiceResult)

A callback function to be called once the API provides a response to the request.

onError function(Error)

A callback function to be called if a communication error occurs during the request.

Returns:
Type Description
H.util.ICancelable a handle that allows to cancel the request.

removeEventListener (type, handler, opt_capture, opt_scope) inherited

This method removes a previously added listener from the EventTarget instance.

Name Type Description
type string

The name of the event

handler function

A previously added event handler

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object optional

An object defining the scope for the handler function