Class: HeatMapLayer

HeatMapLayer

热力图层类。热力图是通过颜色分布,描述诸如人群分布、密度和变化趋势等的一种地图表现手法。 热点图的衰减是像素级别的,视觉效果极佳,但不能与具体数据进行一一对应,只能表示权重之间的差别, 因此可以用于一些对精度要求不高而需要重点突出权重渐变的行业,如制作气象温度对比动态效果图、地震区域的震点强弱图等。
在客户端直接渲染栅格图的三要素:
1.热点数据,热点数据需要点数据,每一个热点数据需要有地理位置以及权重值 (能够明显地表现某位置某事件发生频率或事物分布密度等,如可以为温度的高低、人口密集度等等);
2.热点衰减渐变填充色集合, 用于渲染每一个热点从中心向外衰减时的渐变色;
3.热点半径,也就是衰减半径。每一个热点需要从中心点外四周根据半径计算衰减度,对在热点衰减区内的每一个像素计算需要渲染的颜色值。

new HeatMapLayer(name, loadWhileAnimating, options)

Usage
import { HeatMapLayer } from '@supermapgis/iclient-leaflet';

new HeatMapLayer(name, loadWhileAnimating, options);
<script type="text/javascript" src="https://iclient.supermap.io/dist/leaflet/iclient-leaflet.js"></script>
<script>
  new L.supermap.HeatMapLayer({paramsNames});
</script>
leaflet/overlay/HeatMapLayer.js, line 63
Name Type Default Description
name string

图层名称。

loadWhileAnimating boolean true 可选

是否实时重绘。(当绘制大数据量要素的情况下会出现卡顿,建议把该参数设为 false)。

options Object

构造参数。

Name Type Default Description
map L.Map

Leaflet Map 对象。

id string 可选

专题图层 ID,默认使用 CommonUtil.createUniqueID("heatMapLayer_") 创建专题图层 ID。

alwaysMapCRS boolean false 可选

要素坐标是否和地图坐标系一致,要素默认是经纬度坐标。

featureWeight string 可选

对应 feature 属性中的热点权重字段名称,权重值类型为 number。

radius number 50 可选

热点渲染的最大半径(热点像素半径),单位为 px,当 useGeoUnit 参数 为 true 时,单位使用当前图层地理坐标单位。热点显示的时候以精确点为中心点开始往四周辐射衰减,其衰减半径和权重值成比列。

opacity number 1 可选

图层不透明度。

colors Array.<string> ['blue', 'cyan', 'lime', 'yellow', 'red'] 可选

颜色线性渐变数组,颜色值必须为 canvas 所支持的。

useGeoUnit boolean false 可选

使用地理单位,即默认热点半径默认使用像素单位。当设置为 true 时,热点半径和图层地理坐标保持一致。

blur number 可选

模糊量,单位为 px。默认值为半径的二分之一。

attribution string 'Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' title='SuperMap iServer' target='_blank'>SuperMap iServer</a></span>' 可选

版权描述信息。

Fires

Extends

HeatMapLayer -> L.Layer

Events

changelayer

leaflet/overlay/HeatMapLayer.js, line 535

图层透明度更新成功之后触发。

Properties:
Name Type Description
layer HeatMapLayer

图层。

property string

改变的图层属性。

featuresremoved

leaflet/overlay/HeatMapLayer.js, line 488

删除features成功后触发。

Properties:
Name Type Description
features Array.<FeatureVector>

事件对象。

succeed boolean

删除是否成功,false 为失败,true 为成功。

Methods

addFeatures(features)

leaflet/overlay/HeatMapLayer.js, line 181

添加热点信息。

Name Type Description
features GeoJSONObject | HeatMapFeature

待添加的要素数组。

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",{"id":"heatmap"});
heatMapLayer.addFeatures(geojson);

getLocalXY(coordinate)

leaflet/overlay/HeatMapLayer.js, line 418

地理坐标转为像素坐标。

Name Type Description
coordinate Array

地理坐标。

refresh()

leaflet/overlay/HeatMapLayer.js, line 211

强制刷新当前热点显示,在图层热点数组发生变化后调用,更新显示。

removeAllFeatures()

leaflet/overlay/HeatMapLayer.js, line 498

移除全部的热点信息。

removeFeatures(features)

leaflet/overlay/HeatMapLayer.js, line 459

移除指定的热点信息。

Name Type Description
features Array.<FeatureVector>

热点信息数组。

setOpacity(opacity)

leaflet/overlay/HeatMapLayer.js, line 443

设置图层的不透明度,取值范围:[0-1]。

Name Type Description
opacity number

不透明度。

toiClientFeature(features){FeatureVector}

leaflet/overlay/HeatMapLayer.js, line 564

转为 iClient 要素。

Name Type Description
features GeoJSONObject | HeatMapFeature

待添加的要素数组。

Returns:
Type Description
FeatureVector 转换后的 iClient 要素。

update()

leaflet/overlay/HeatMapLayer.js, line 395

更新图层。

updateHeatPoints(bounds)

leaflet/overlay/HeatMapLayer.js, line 225

刷新热点图显示。

Name Type Description
bounds L.LatLngBounds

当前显示范围。