Maps API for JavaScript Developer's Guide

H.data.heatmap.Provider

Class Summary

Extends: H.map.provider.RemoteTileProvider

This class provides tiles to visualize value-based or density-based heat maps. The user can choose between density and value based heat map.

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

addData (dataPoints, opt_hardReload)

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.

clear ()

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.

Class Description

This class provides tiles to visualize value-based or density-based heat maps. The user can choose between density and value based heat map.

Example

// Create heat map provider
var heatmapProvider = new H.data.heatmap.Provider({
  colors: new H.data.heatmap.Colors({
  '0': 'blue',
  '0.5': 'yellow',
  '1': 'red'
  }, true),
  // 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}
]);

// Create a semi-transparent heat map layer
var heatmapLayer = new H.map.layer.TileLayer(heatmapProvider, {
  opacity: 0.6
});

// Add the layer to the map
map.addLayer(heatmapLayer);

Constructor Details

H.data.heatmap.Provider(opt_options)

Parameters:
 
opt_options:
{H.data.heatmap.Provider.Options=} [optional]
 
An object containing configuration options
Throws:
 
{H.lang.InvalidArgumentError}
 
If colors or tileSize option is invalid

Method Details

addData (dataPoints, opt_hardReload)

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.

Parameters:
 
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 in soft mode (false), the default is soft mode.
Throws:
 
{H.lang.InvalidArgumentError}
 
If data is not specified

clear ()

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.