Class: Provider
- Last UpdatedMay 21, 2025
- 9 minute read
This class provides tiles to visualize value-based or density-based heat maps. The user can choose between density and value based heat map.
Name | Type | Description |
---|---|---|
opt_options |
H.data.heatmap.Provider.Options |
optional
An object containing configuration options |
Throws:
-
If
colors
ortileSize
option is invalid
Example
// Create a provider for a semi-transparent heat map:
var heatmapProvider = new H.data.heatmap.Provider({
colors: new H.data.heatmap.Colors({
'0': 'blue',
'0.5': 'yellow',
'1': 'red'
}, true),
opacity: 0.6,
// Paint assumed values in regions where no data is available
assumeValues: true
});
// Add the data:
heatmapProvider.addData([
{lat: 52, lng: 1, value: 1},
{lat: 53, lng: 2, value: 2}
]);
// Add a layer for the heatmap provider to the map:
map.addLayer(new H.map.layer.TileLayer(heatmapProvider));
Extends
Members
-
max number inherited
-
This property holds a value indicating the maximum zoom level at which the given provider can serve data. The value is set at construction time.
-
min number inherited
-
This property holds a value indicating the minimum zoom level at which the given provider can serve data. The value is set at construction time.
-
This method checks whether this provider will provide bitmap images as tiles. A concrete implementation of
Provider
must override it if it will provide raster tiles. -
tileSize number inherited
-
This property holds the size of a tile representing edge length in pixels. Its value must be
2^n
where n is in range[0…30]
, default is256
. -
uid string inherited
-
This property holds the unique identifier for the provider instance. The value is generated at construction time.
-
uri string inherited
-
This property holds the provider's unique resource identifier. If it is not provided at construction time, it defaults to provider's
uid
.
Methods
-
This method adds an array of data points
H.data.heatmap.IDataPoint
to the heat map. The heat map provides a visual representation of these data points. Note that there is a significant performance cost to adding and removing data, once an overlay has been created. This is related to the rendering engine and tile caching. If you wish to add data after the tiles have been created, the cache must be cleared and all tiles need to be recreated. For this reason, heat maps should not be used to create fast animations.As new data can invalidate the already generated tiles, those tiles should be removed form the tile cache. Use the argument
opt_hardReload
to change the mode determining how those tiles are removed. Two modes are supported:-
hard
: This mode immediately removes the cached tiles from the tile cache and forces the provider to re-fetch the tiles. Currently cached tiles are not used for rendering. -
soft
: This mode only 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.
Name Type Description dataPoints
Array.<!H.data.heatmap.IDataPoint> An array of data points to add
opt_hardReload
boolean optional A value indicating whether to invalidate in
hard
mode (true
) or insoft
mode (false
), the default issoft
mode.Throws:
-
If data is not specified
-
-
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
ordispose
on the given object when you no longer need it. -
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
-
cancelTile (x, y, z) inherited
-
This method cancels a tile request, using the caller-supplied tile coordinates.
-
cancelTileByKey (tileKey) inherited
-
This method cancels a tile request, using a tile key.
Name Type Description tileKey
string The key identifying the tile
-
This method removes all data from the given heat map provider object. New data can be added using the method
H.data.heatmap.Provider#addData
. -
createTileInternal (x, y, z, data, opt_options)H.map.provider.Tile inherited
-
The internal method to create a tile. It must be overridden by sub-classes.
Returns:
Type Description H.map.provider.Tile The created tile -
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. -
getCache ()H.util.ICache inherited
-
This method retrieves a tile cache of this provider.
Returns:
Type Description H.util.ICache An object representing a tile cache -
getCopyrights (boundingBox, level)Array.<!H.map.ICopyright> inherited
-
This method retrieves the copyrights for the provided content for a certain geographical area and zoom level.
Note: This function may be overridden by
H.map.provider.Provider.Options
getCopyrights
property. The default implementation returnsnull
.Name Type Description boundingBox
H.geo.Rect The rectangular area for which to retrieve the copyright information
level
number The zoom level for which to retrieve the copyright information
Returns:
Type Description Array.<!H.map.ICopyright> A list of copyright information objects for the provided area and zoom level -
To obtain the opacity which is used for the rendering of the heatmap. See
setOpacity
for more details.Returns:
Type Description number -
getStyleInternal ()H.map.render.Style.<!Object> inherited
-
This methods returns the style used to render the provider data.
Returns:
Type Description H.map.render.Style.<!Object> -
getTileKey (x, y, z)string inherited
-
This method creates a tile key consisting of the provider's URI, and the x, y and z coordinates of the tile, separated by underscores, for example "4711_7_42_23".
Returns:
Type Description string A string containing the tile key -
providesDomMarkers ()boolean inherited
-
This method checks whether this provider will provide
DomMarker
map objects. A concrete implementation ofProvider
must override it if it will provideDomMarker
s.Returns:
Type Description boolean A value indicating if the given provider provides DomMarkers ( true
) or not (false
) -
providesGeoJSON ()boolean inherited
-
This method checks whether this provider will provide data in
GeoJSON
format. A concrete implementation ofProvider
must override it if it will provideGeoJSON
data.Returns:
Type Description boolean A value indicating if the given provider provides GeoJSON
data (true
) or not (false
) -
providesMarkers ()boolean inherited
-
This method checks whether this provider will provide
Marker
map objects. A concrete implementation ofProvider
must override it if it will provideMarker
s.Returns:
Type Description boolean A value indicating if the given provider provides Markers ( true
) or not (false
) -
providesOMV ()boolean inherited
-
This method checks whether this provider will provide data in
OMV
format. A concrete implementation ofProvider
must override it if it will provideOMV
data.Returns:
Type Description boolean A value indicating if the given provider provides OMV
data (true
) or not (false
) -
providesOverlays ()boolean inherited
-
This method checks whether this provider will provide overlay map objects. A concrete implementation of
Provider
must override it if it will provide overlays.Returns:
Type Description boolean true
if the provider provides overlays, otherwisefalse
-
providesSpatials ()boolean inherited
-
This method checks whether this provider will provide spatial map objects. A concrete implementation of
Provider
must override it if it will provideSpatial
s.Returns:
Type Description boolean A value indicating whether the provider provides map objects ( true
) or not (false
) -
reload (hard) inherited
-
This method instructs the provider to reload data from its source.
Two reload modes are possible:
hard
: This mode immediately removes tiles from the tile cache and forces the provider to re-fetch them. Currently cached tiles are not used for rendering.soft
: This mode only marks tiles as invalid and requests the tiles to be re-fetched as soon as possible. The provider does not invalidate the cache immediately. This means that cached tiles can still be rendered while the updated tiles are fetched.
Name Type Description hard
boolean A Boolean flag indicating whether to invalidate in
hard
mode (true
) or insoft
mode (false
); -
removeEventListener (type, handler, opt_capture, opt_scope) inherited
-
This method removes a previously added listener from the
EventTarget
instance. -
requestInternal (x, y, z, onResponse, onError, opt_priority)H.util.ICancelable inherited overrides
-
To request a tile from a remote service. This method must be implemented by deriving classes.
Returns:
Type Description H.util.ICancelable An object implementing ICancelable
-
requestTile (x, y, z, cacheOnly)H.map.provider.Tile | undefined inherited
-
This method requests data for a tile.
Returns:
Type Description H.map.provider.Tile | undefined The tile object if it can be obtained, otherwise undefined
-
To set the opacity which is used for the rendering of the heatmap.
Name Type Description opt_opacity
number optional The opacity to set in range
[0..1]
where0.0
means full transparent and1.0
means full opaque. The default value is1.0
-
setStyleInternal (style, opt_suppressChangeEvent) inherited
-
This method sets the style to be used to render the provider data.
Name Type Description style
H.map.render.Style.<!Object> The style to use for rendering the provider data.
opt_suppressChangeEvent
boolean optional Flag to suppress firing of config change event.
Type Definitions
-
This type encapsulates configuration (initialization) options for the heat map
Provider
.Properties:
Events
-
update inherited
-
Event fired when this provider's data updates.
Type: