Maps API for JavaScript Developer's Guide

H.service.TrafficIncidentsProvider

Class Summary

Extends: H.map.provider.MarkerTileProvider

This class represents a traffic incidents provider which requests traffic incident data from the platform traffic incidents service and converts it to map objects.

[ For full details, see the Class Details ]

Property Summary

Table 1. Properties
Properties

min : {number}

This property holds the minimum zoom level at which the provider can server data. The value is set at construction time.

max : {number}

This property holds the maximum zoom level at which the provider can server data. The value is set at construction time.

uid : {string}

This property holds a unique identifier for the provider instance. The value is generated at construction time.

tileSize : {number}

This property holds the size of a tile expressed as the length of the tile side in pixels. It must be 2^n, where n is in the range [0 ... 30], default is 256.

Method Summary

Table 2. Methods
Methods

addEventListener (type, handler, opt_capture, opt_scope)

This method adds a listener for a specific event triggered by the object.

removeEventListener (type, handler, opt_capture, opt_scope)

This method removes a previously added listener from the event target

dispatchEvent (evt)

This method dispatches an event on the event target object.

dispose ()

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.

addOnDisposeCallback (callback, opt_scope)

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

getCopyrights (bounds, level) : {?Array<H.map.ICopyright>}

This method retrieves the copyright information for map content in a certain geographical area displayed at a specific zoom level.

requestTile (x, y, z, cacheOnly) : {(H.map.provider.Tile | undefined)}

This method request a tile.

cancelTile (x, y, z)

This method cancels a tile request based on the tile coordinates (column, row) and zoom level.

cancelTileByKey (tileKey)

This method cancels a tile request based on a tile key.

getTileKey (x, y, z) : {string}

This method creates a tile key consisting of the provider's UID, and the x, y and z coordinates of the tile, seperated by underscores, for example "4711_7_42_23".

getCache () : {H.util.Cache}

This method retrieves a tile cache.

requestInternal (x, y, z, onResponse, onError) : {H.util.ICancelable}

This method request a tile from the remote service.

reload (hard)

This method instructs the provider to reload data from its source.

invalidateObject (marker, flags)

This method signals to the given provider that a map object has changed. The method marks the tile that contains the object as invalid and triggers a call to dispatchUpdate().

providesDomMarkers () : {boolean}

This method checks whether the given provider provides H.map.DomMarker objects.

Class Description

This class represents a traffic incidents provider which requests traffic incident data from the platform traffic incidents service and converts it to map objects.

Constructor Details

H.service.TrafficIncidentsProvider(service, opt_refreshTime, opt_additionalParameters)

Parameters:
 
service:
{H.service.TrafficIncidentsService}
 
An object representing a traffic incidents service that serves incidents data
opt_refreshTime:
{number=} [optional]
 
A value indicating an interval between provider tiles updates (in ms), defaults to 3 minutes
opt_additionalParameters:
{H.service.ServiceParameters=} [optional]
 
An object containing an additional set of URL parameters

Property Details

min: {number}

This property holds the minimum zoom level at which the provider can server data. The value is set at construction time.

max: {number}

This property holds the maximum zoom level at which the provider can server data. The value is set at construction time.

uid: {string}

This property holds a unique identifier for the provider instance. The value is generated at construction time.

tileSize: {number}

This property holds the size of a tile expressed as the length of the tile side in pixels. It must be 2^n, where n is in the range [0 ... 30], default is 256.

Method Details

addEventListener (type, handler, opt_capture, opt_scope)

This method adds a listener for a specific event triggered by the object.

Parameters:
 
type:
{string}
 
An indicator of the event type
handler:
{!Function}
 
An event handler function
opt_capture:
{boolean=} [optional]
 
true indicates that monitoring for the event is to include the capture phase (bubble otherwise)
opt_scope:
{Object=} [optional]
 
An object representing the scope for the handler function

removeEventListener (type, handler, opt_capture, opt_scope)

This method removes a previously added listener from the event target

Parameters:
 
type:
{string}
 
An indicator of the event type
handler:
{!Function}
 
A previously added event handler
opt_capture:
{boolean=} [optional]
 
true indicates that monitoring for the event is to include the capture phase (bubble otherwise)
opt_scope:
{Object=} [optional]
 
An object representing the scope for the handler function

dispatchEvent (evt)

This method dispatches an event on the event target object.

Parameters:
 
evt:
{(H.util.Event | string)}
 
An object representing the event or the identifier of the event

dispose ()

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.

addOnDisposeCallback (callback, opt_scope)

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

Parameters:
 
callback:
{!Function}
 
The callback function to invoke
opt_scope:
{Object=} [optional]
 
An object representing the scope for the callback

getCopyrights (bounds, level) : {?Array<H.map.ICopyright>}

This method retrieves the copyright information for map content in a certain geographical area displayed at a specific zoom level.

Note: This function must be overridden by any class derived from Provider. The default implementation returns null.

Parameters:
 
bounds:
{H.geo.Rect}
 
The bounding area for which to retrieve the copyright information
level:
{number}
 
The zoom level for which to retrieve the copyright information
Returns:
 
{?Array<H.map.ICopyright>}
A list of copyright information objects for the specified area and zoom level

requestTile (x, y, z, cacheOnly) : {(H.map.provider.Tile | undefined)}

This method request a tile.

Parameters:
 
x:
{number}
 
A value indicating the row number of the tile
y:
{number}
 
A value indicating the column number of the tile
z:
{number}
 
A value indicating the zoom level for which the tile is requested
cacheOnly:
{boolean}
 
A value indicating whether only cached tiles are to be considered (true)
Returns:
 
{(H.map.provider.Tile | undefined)}
A map tile object or undefined if the tile is not available

cancelTile (x, y, z)

This method cancels a tile request based on the tile coordinates (column, row) and zoom level.

Parameters:
 
x:
{number}
 
A value indicating the row number of the tile
y:
{number}
 
A value indicating the column number of the tile
z:
{number}
 
A value indicating the zoom level for which the tile is requested

cancelTileByKey (tileKey)

This method cancels a tile request based on a tile key.

Parameters:
 
tileKey:
{string}
 
The key identifying the tile

getTileKey (x, y, z) : {string}

This method creates a tile key consisting of the provider's UID, and the x, y and z coordinates of the tile, seperated by underscores, for example "4711_7_42_23".

Parameters:
 
x:
{number}
 
A value indicating the row number of the tile
y:
{number}
 
A value indicating the column number of the tile
z:
{number}
 
A value indicating the zoom level for which the tile is requested
Returns:
 
{string}
string A string containing the generated tile key

getCache () : {H.util.Cache}

This method retrieves a tile cache.

Returns:
 
{H.util.Cache}
cache An object representing a cache which stores tiles

requestInternal (x, y, z, onResponse, onError) : {H.util.ICancelable}

This method request a tile from the remote service.

Parameters:
 
x:
{number}
 
A value indicating the row number of the requested tile
y:
{number}
 
A value indicating the column number of the requested tile
z:
{number}
 
A value indicating the zoom level for which the tile is requested
onResponse:
{function((Array<H.map.Object> | HTMLImageElement | HTMLCanvasElement | null))}
 
A function which is called when the response arrives
onError:
{function(string)}
 
A function which is called if a communication error occurs
Returns:
 
{H.util.ICancelable}

reload (hard)

This method instructs the provider to reload data from its source.

Two reload modes are supported:

  • hard: This method immediately removes the cached tiles from the tile cache and forces the provider to re-fetch the tiles. Any currently cached tiles are not used for rendering.
  • soft: This method marks tiles as invalid and requests the tiles to be re-fetched at the earliest opportunity. The provider does not invalidate the cache immediately in this case. This means that cached tiles can still be rendered while the updated tiles are fetched.
Parameters:
 
hard:
{boolean}
 
A Boolean flag indicating whether to invalidate in hard mode (true) or in soft mode (false);

invalidateObject (marker, flags)

This method signals to the given provider that a map object has changed. The method marks the tile that contains the object as invalid and triggers a call to dispatchUpdate().

Parameters:
 
marker:
{!H.map.AbstractMarker}
 
The map object to be invalidated
flags:
{H.math.BitMask}
 
The flags indicating the types of changes that occurred

providesDomMarkers () : {boolean}

This method checks whether the given provider provides H.map.DomMarker objects.

Returns:
 
{boolean}
true indicates that the provider provides DomMarker objects