new mapboxgl.supermap.HeatMapLayer(name, options)
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string |
The name of the layer. |
||||||||||||||||||||||||||||||||||||
options |
Object |
Construction parameters.
|
Fires
Extends
Members
-
canvasContextObject
-
The main drawing object of the heat map.
-
colorsArray.<string>
-
A linear gradient array of colors, the color value must be canvas.
- Default Value: ['blue','cyan','lime','yellow','red']
EVENT_TYPES
Listening for a custom event can be done as follows: The hotspot map customizes the event information, and the attributes when the event is called correspond to the specific event type.
All event objects have at least the following properties: {Object} object - A reference to layer.events.object. {DOMElement} element - A reference to layer.events.element.
The supported events are as follows (also contains
featuresArray.<SuperMap.Feature.Vector>
An array of hotspot information that records information about all hotspots added to the storage layer.
featureWeightstring
Corresponds to the hotspot weight field name in the feature attribute, and the weight value type is float.
Example
//The field representing the weight in feature.attributes is height, and the featureWeight parameter of the HeatMapLayer is assigned the value "height".
feature1.attributes.height = 7.0;
feature2.attributes.height = 6.0;
var heatMapLayer = new mapboxgl.supermap.HeatMapLayer("heatmaplayer",{"featureWeight":"height"});
heatMapLayer.addFeatures([feature1,feature2]);
idstring
The id of the heat map layer.
loadWhileAnimatingboolean
Whether to redraw in real time. (The card will appear when drawing large data elements, it is recommended to set this parameter to false).
- Default Value: true
mapmapboxgl.Map
The map of the heat map layer.
maxHeightnumber
The current panel width is drawn. It is the same height as the current map window.
maxWeightnumber
Set the maximum weight. If you do not set this property, the heatmap will be drawn according to the maximum weight of the hotspots in the current screen range.
maxWidthnumber
The current panel width is drawn. Consistent with the width of the current map window.
minWeightnumber
Set the minimum weight. If this property is not set, the heat map will be drawn according to the minimum weight of the hotspots in the current screen range.
namestring
The name of the layer.
opacitynumber
The transparency of the layer, in the range [0,1].
- Default Value: 1
radiusnumber
The maximum radius of the hotspot rendering (hotspot pixel radius), When the hot spot is displayed, the radiation point is attenuated around the center point with the precise point, Its attenuation radius and weight value are proportional.
- Default Value: 50
rootCanvasObject
The main drawing panel of the heat map.
supportedboolean
Whether the current browser supports canvas drawing, It is determined whether the hot map is available or not, and internal judgment is used.
useGeoUnitboolean
Use the geographic unit, which is the default pixel radius by default. When set to true, the hotspot radius and the layer's geographic coordinates are consistent.
visibilityboolean
The layer displays the status attribute.
- Default Value: true
Events
-
changelayer
HeatMapLayer.js, line 297 -
Fires after the layer property changes.
Properties:
Name Type Description layer
Object Layer.
property
string The layer property being changed.
-
featuresadded
HeatMapLayer.js, line 260 -
Fires when the feature is added.
Properties:
Name Type Description features
GeoJSONObject The added elements.
succeed
boolean Whether the feature was successfully added.
-
featuresremoved
HeatMapLayer.js, line 557 -
Triggered after the feature is deleted.
Properties:
Name Type Description features
Array.<SuperMap.Feature.Vector> The features that need to be deleted.
succeed
boolean Whether the feature was deleted successfully.
Methods
-
addFeatures(features)
HeatMapLayer.js, line 232 -
Add information about the hotspot.
Name Type Description features
GeoJSONObject An array of features to be added that supports the GeoJOSN specification data type.
Example
var geojson = { "type": "FeatureCollection", "features": [ { "type": "feature", "geometry": { "type": "Point", "coordinates": [0, 0] }, "properties": { "height": Math.random()*9, "geoRadius": useGeoRadius?radius:null } } ] }; var heatMapLayer = new mapboxgl.supermap.HeatMapLayer("heatmaplayer",{"featureWeight":"height"}); pLayer = new mapboxgl.supermap.HeatMapLayer("heatmaplayer",{"featureWeight":"height"}); heatMapLayer.addFeatures(geojson); map.addLayer(heatMapLayer);
-
getPixelXY(x, y)
HeatMapLayer.js, line 481 -
Convert the geographic coordinates to the pixel coordinates relative to the top left corner of the current window.
Name Type Description x
number The pixel x coordinate of the hotspot.
y
number The pixel y coordinate of the hotspot.
-
moveTo(layerID, before)
HeatMapLayer.js, line 576 -
Move the layer before a layer.
Name Type Default Description layerID
string The layer ID to be inserted.
before
boolean true optional Whether to insert this layer before the layer whose layer id is layerID (if it is false, insert this layer after the layer whose layer id is layerID).
-
onAdd()
HeatMapLayer.js, line 174 -
Add this layer to the basemap。
-
refresh()
ThemeLayer.js, line 104 -
Forces the current hotspot display to be refreshed. It is called after the layer hotspot array has changed, and the display is updated.
-
refresh()
ThemeLayer.js, line 104 -
Forces the current hotspot display to be refreshed. It is called after the layer hotspot array has changed, and the display is updated.
-
removeAllFeatures()
HeatMapLayer.js, line 567 -
Remove all hotspot information.
-
removeFeatures(features)
HeatMapLayer.js, line 528 -
Remove the specified hotspot information.
Name Type Description features
Array.<SuperMap.Feature.Vector> An array of hotspot information.
-
removeFromMap()
HeatMapLayer.js, line 201 -
Remove the layer from the basemap.
-
setOpacity(opacity)
HeatMapLayer.js, line 285 -
Set the opacity of the layer, between values [0-1].
Name Type Description opacity
number optional opacity.
-
setVisibility(visibility)
HeatMapLayer.js, line 602 -
Set the visibility of the layer, set the hidden, displayed, and redrawed corresponding visible markers.
Name Type Description visibility
boolean optional Whether to display the layer (the resolution of the current map is between the maximum and minimum resolutions).
-
toiClientFeature(features)
HeatMapLayer.js, line 500 -
Switch to the iClient element.
Name Type Description features
GeoJSONObject An array of features to be added that supports the GeoJOSN specification data type.
-
updateHeatPoints(bounds)
HeatMapLayer.js, line 308 -
Refresh the hot map display.
Name Type Description bounds
mapboxgl.LngLatBounds The range currently displayed.