new HeatMapLayer(name, options)
Usage
import { HeatMapLayer } from '@supermapgis/iclient-mapboxgl';
new HeatMapLayer(name, options);<script type="text/javascript" src="https://iclient.supermap.io/dist/mapboxgl/iclient-mapboxgl.js"></script>
<script>
new mapboxgl.supermap.HeatMapLayer({paramsNames});
</script>| Name | Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string |
图层名称。 |
||||||||||||||||||||||||||||||||||||
options |
Object |
构造参数。
|
Fires
Extends
Members
-
EVENT_TYPES
-
监听一个自定义事件可用如下方式: 热点图自定义事件信息,事件调用时的属性与具体事件类型相对应。
支持的事件如下 (另外包含 <Layer 中定义的其他事件>):
featuresadded - 热点添加完成时触发。回调参数为添加的热点信息数组和操作成功与否信息。 参数类型:{features: features, succeed: succeed} featuresremoved - 热点被删除时触发。回调参数为删除的热点信息数组和操作成功与否信息。
参数类型:{features: features, succeed: succeed} featuresdrawcompleted - 热点图渲染完成时触发。 -
featuresGeoJSONObject
-
热点信息数组,记录存储图层上添加的所有热点信息。
-
idstring
-
热力图图层 ID。
-
loadWhileAnimatingboolean
-
是否实时重绘。(当绘制大数据量要素的情况下会出现卡顿,建议把该参数设为 false)。
- Default Value: true
namestring
图层名字。
Events
-
changelayer
mapboxgl/overlay/HeatMapLayer.js, line 175 -
图层属性改变之后触发。
Properties:
Name Type Description layerObject 图层。
propertystring 被改变的图层属性。
-
featuresadded
mapboxgl/overlay/HeatMapLayer.js, line 146 -
要素添加完成之后触发。
Properties:
Name Type Description featuresGeoJSONObject 被添加的要素。
succeedboolean 要素是否成功添加。
-
featuresremoved
mapboxgl/overlay/HeatMapLayer.js, line 217 -
要素删除之后触发。
Properties:
Name Type Description featuresArray.<FeatureVector> 需要被删除的要素。
succeedboolean 要素删除成功与否。
Methods
-
addFeatures(features)
mapboxgl/overlay/HeatMapLayer.js, line 114 -
添加热点信息。
Name Type Description featuresGeoJSONObject 待添加的要素数组。
Example
var geojson = { "type": "FeatureCollection", "features": [ { "type": "feature", "geometry": { "type": "Point", //只支持point类型 "coordinates": [0, 0] }, "properties": { "height": Math.random()*9, "geoRadius": useGeoRadius?radius:null } } ] }; var heatMapLayer = new HeatMapLayer("heatmaplayer",{"featureWeight":"height"}); pLayer = new HeatMapLayer("heatmaplayer",{"featureWeight":"height"}); heatMapLayer.addFeatures(geojson); map.addLayer(heatMapLayer); -
getPixelXY(x, y)
mapboxgl/overlay/HeatMapLayer.js, line 195 -
转换地理坐标为相对于当前窗口左上角的像素坐标。
Name Type Description xnumber 热点的像素 x 坐标。
ynumber 热点的像素 y 坐标。
-
moveTo(layerID, before)
mapboxgl/overlay/HeatMapLayer.js, line 234 -
将图层移动到某个图层之前。
Name Type Default Description layerIDstring 待插入的图层 ID。
beforeboolean true 可选 是否将本图层插入到图层 ID 为 layerID 的图层之前(如果为 false 则将本图层插入到图层 ID 为 layerID 的图层之后)。
-
onAdd()
mapboxgl/overlay/HeatMapLayer.js, line 84 -
添加该图层。
-
refresh()
mapboxgl/overlay/HeatMapLayer.js, line 155 -
强制刷新当前热点显示,在图层热点数组发生变化后调用,更新显示。
-
removeAllFeatures()
mapboxgl/overlay/HeatMapLayer.js, line 226 -
移除全部的热点信息。
-
removeFeatures(features)
mapboxgl/overlay/HeatMapLayer.js, line 205 -
移除指定的热点信息。
Name Type Description featuresArray.<FeatureVector> | FeatureVector 热点信息数组。
-
removeFromMap()
mapboxgl/overlay/HeatMapLayer.js, line 99 -
删除该图层。
-
setOpacity(opacity)
mapboxgl/overlay/HeatMapLayer.js, line 166 -
设置图层的不透明度,取值范围:[0-1]。
Name Type Description opacitynumber 可选 不透明度。
-
setVisibility(visibility)
mapboxgl/overlay/HeatMapLayer.js, line 260 -
设置图层可见性。
Name Type Description visibilityboolean 可选 是否显示图层(当前地图的 resolution 在最大最小 resolution 之间)。
-
updateHeatPoints(bounds)
mapboxgl/overlay/HeatMapLayer.js, line 186 -
刷新热点图显示。
Name Type Description boundsmapboxgl.LngLatBounds 当前显示范围。