This class encapsulates the HERE Traffic API v6 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 |
|---|---|---|
opt_options |
H.service.traffic.Service.Options |
optional
Configuration options for traffic service |
Throws:
Example
// Assumption: the platform is instantiated
platform.getTrafficService().requestIncidentsByTile(
8192, 5450, 14, // x, y, z - London
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
-
createFlowLayer (opt_additionalParameters, opt_engineType)H.map.layer.TileLayer
-
To create a traffic flow tile layer.
Name Type Description opt_additionalParametersH.service.ServiceParameters optional An object containing an additional set of URL parameters
opt_engineTypeH.Map.EngineType optional The engine type used in the map to properly configure the layer's provider style Default is
H.Map.EngineType.WEBGL.Returns:
Type Description H.map.layer.TileLayer -
createIncidentsLayer (opt_additionalParameters)H.map.layer.MarkerTileLayer
-
To create a traffic incidents marker tile layer.
Name Type Description opt_additionalParametersH.service.ServiceParameters optional An object containing an additional set of URL parameters
Returns:
Type Description H.map.layer.MarkerTileLayer -
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 -
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
-
requestFlowByTile (x, y, z, onResult, onError, opt_serviceParams)H.service.JsonpRequestHandle
-
This method requests traffic flow data by tile coordinates
Name Type Description xnumber tile column number
ynumber tile row number
znumber zoom level
onResultfunction(H.service.ServiceResult) onErrorfunction(Error) opt_serviceParamsH.service.ServiceParameters optional optional service parameters to be added to the request
Returns:
Type Description H.service.JsonpRequestHandle -
requestIncidents (serviceParams, onResult, onError)H.service.JsonpRequestHandle
-
This method requests traffic incidents based on the service parameters provided.
Name Type Description serviceParamsH.service.ServiceParameters onResultfunction(H.service.ServiceResult) onErrorfunction(Error) Returns:
Type Description H.service.JsonpRequestHandle -
requestIncidentsByTile (x, y, z, onResult, onError, opt_serviceParams)H.service.JsonpRequestHandle
-
This method requests traffic incident information by tile coordinates
Name Type Description xnumber tile column number
ynumber tile row number
znumber zoom level
onResultfunction(H.service.ServiceResult) callback to handle a service response
onErrorfunction(Error) callback to handle a communication error
opt_serviceParamsH.service.ServiceParameters optional optional service parameters to be added to the request
Returns:
Type Description H.service.JsonpRequestHandle
Type Definitions
-
This type encapsulates configuration options for an instance of a Traffic service.
Properties:
Name Type Argument Description baseUrlH.service.Url <optional>
The base URL of the traffic service. If supplied, it overrides all defaults (either coming from platform or service internals) including authentication params
subDomainstring <optional>
the subdomain of the traffic service relative to the platform's base URL, the default is
"traffic"pathstring <optional>
the path of the traffic service, default is
"traffic/6.1"callbackKeystring <optional>
Callback name needed for JSONP requests