This class encapsulates the HERE Traffic API v7 in a service stub, providing methods to access its resources.
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#getTrafficService 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 traffic service |
Throws:
Example
// Assumption: the platform is instantiated
platform.getTrafficService().requestIncidentsByArea(
{
in: "circle:52.5189,13.4158;r=15000", // traffic incidents in Berlin within a 15km radius
locationReferencing: 'shape'
},
console.log,
console.error
);
Extends
Members
-
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
removeEventListenerordisposeon the given object when you no longer need it.Name Type Description typestring The name of the event
handlerfunction An event handler function
opt_captureboolean optional trueindicates that the method should listen in the capture phase (bubble otherwise)opt_scopeObject 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
EventTargetobject is being disposed.Name Type Description callbackfunction The callback function.
opt_scopeObject optional An optional scope for the callback function
-
dispatchEvent (evt) inherited
-
This method dispatches an event on the
EventTargetobject.Name Type Description evtH.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
EventTargetmay need to override this method in order to remove references to DOM Elements and additional listeners. -
getUrl ()H.service.Url inherited
-
This method returns the configured service URL.
Returns:
Type Description H.service.Url -
postRequestFlowByArea (params, body, onResult, onError)H.util.ICancelable
-
This method sends a
POSTrequest to the Traffic API v7. It returns traffic flow information within a specified area.It calls the
onResultcallback function once the service response becomes available (providing aH.service.ServiceResultobject) or theonErrorcallback if a communication error occurred.Please refer to the Traffic API v7 documentation for information on available parameters and the response object structure.
Name Type Description paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
bodyH.service.ServiceParameters Contains the request body to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(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. -
postRequestIncidentById (originalId, params, body, onResult, onError)H.util.ICancelable
-
This method sends a
POSTrequest to the Traffic API v7. It returns traffic incidents based on the service parameters provided.It calls the
onResultcallback function once the service response becomes available (providing aH.service.ServiceResultobject) or theonErrorcallback if a communication error occurred.Please refer to the Traffic API v7 documentation for information on available parameters and the response object structure.
Name Type Description originalIdstring Identifier of the first traffic incident in a chain of updates.
paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
bodyH.service.ServiceParameters Contains the request body to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(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. -
postRequestIncidentsByArea (params, body, onResult, onError)H.util.ICancelable
-
This method sends a
POSTrequest to the Traffic API v7. It returns traffic incident information within a specified area.It calls the
onResultcallback function once the service response becomes available (providing aH.service.ServiceResultobject) or theonErrorcallback if a communication error occurred.Please refer to the Traffic API v7 documentation for information on available parameters and the response object structure.
Name Type Description paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
bodyH.service.ServiceParameters Contains the request body to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(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
EventTargetinstance.Name Type Description typestring The name of the event
handlerfunction A previously added event handler
opt_captureboolean optional trueindicates that the method should listen in the capture phase (bubble otherwise)opt_scopeObject optional An object defining the scope for the handler function
-
requestFlowByArea (params, onResult, onError)H.util.ICancelable
-
This method sends a
GETrequest to the Traffic API v7. It requests traffic flow information within a specified area.Please refer to the Traffic API v7 documentation for information on available parameters and the response object structure.
Name Type Description paramsH.service.ServiceParameters service parameters to be added to the request
onResultfunction(H.service.ServiceResult) callback to handle a service response
onErrorfunction(Error) callback to handle a communication error
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request. -
requestIncidentById (originalId, params, onResult, onError)H.util.ICancelable
-
This method sends a
GETrequest to the Traffic API v7. It requests traffic incidents based on the service parameters provided.Please refer to the Traffic API v7 documentation for information on available parameters and the response object structure.
Name Type Description originalIdstring Identifier of the first traffic incident in a chain of updates
paramsH.service.ServiceParameters service parameters to be added to the request
onResultfunction(H.service.ServiceResult) callback to handle a service response
onErrorfunction(Error) callback to handle a communication error
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request. -
requestIncidentsByArea (params, onResult, onError)H.util.ICancelable
-
This method sends a
GETrequest to the Traffic API v7. It requests traffic incident information within a specified area.Please refer to the Traffic API v7 documentation for information on available parameters and the response object structure.
Name Type Description paramsH.service.ServiceParameters service parameters to be added to the request
onResultfunction(H.service.ServiceResult) callback to handle a service response
onErrorfunction(Error) callback to handle a communication error
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request.