GeoHeatMapEffectLayer

new Cesium.GeoHeatMapEffectLayer(options)

热力图特效图层类
Name Type Description
options Object optional 参数选项:
Name Type Description
effectType String optional 特效类型,值可以为"HeatMap2D", "HeatMap3D"之一
effectTypeMapField String optional 特效类型映射字段,图层中的特效实体类型由指定的要素对象字段值决定
valueMapField String optional 指定热力值对应字段名称
heatmap2dOptions Object optional 二维热力图配置项,具体使用方法参见下面示例代码
Name Type Description
useEntities Object optional 值为true:采用entities方式加载;值为false:采用imageryLayers方式加载
gradient Object optional 渐变颜色描述
radius Object optional 每个数据点将具有的半径
spacingFactor Object optional 边界周围的额外空间(点半径乘以此数字得到间距)
radiusFactor Object optional 如果没有给定半径,则使用数据点大小因子(高度和宽度的较大值除以该数字将生成所用的半径)
opacity Object optional 整个热力图的全局不透明度。如果设置,这将覆盖maxOpacity和minOpacity
maxOpacity Object optional 热力图中最高值的最大不透明度。(如果设置了不透明度,将被覆盖)
minOpacity Object optional 热力图中最低值的最小不透明度(如果设置了不透明度,将被覆盖)
blur Object optional 值越大,渐变越平滑,外圆占比越大。
heatmap3dOptions Object optional 三维热力图配置项,具体使用方法参见下面示例代码
Name Type Description
gradient Object optional 渐变颜色描述
radius Number optional 每个数据点将具有的半径
maxOpacity Number optional 热力图中最高值的最大不透明度。(如果设置了不透明度,将被覆盖)
minOpacity Number optional 热力图中最低值的最小不透明度(如果设置了不透明度,将被覆盖)
blur Number optional 值越大,渐变越平滑,外圆占比越大。
height Number optional 三维热力图元最下端与球面的距离
extrudedHeight Number optional 三维热力图元最上端与球面的距离
granularity Number optional 该值决定了图元顶点的数量。值越小,顶点数量越多,则渲染越平滑,相应地帧数会降低。反之,值越大,顶点数量越少,则渲染越不平滑,相应地帧数也会上升。
Author:
  • zj
Example:
//构造本地geojson数据

	var heatMapEffectLayer = new Cesium.GeoHeatMapEffectLayer({
		effectType: "HeatMap3D",
		valueMapField: '统计数',
		heatmap3dOptions: {
			gradient: { //渐变颜色描述
				0.25: "rgb(0,0,225)",
				0.55: "rgb(0,225,0)",
				0.85: "rgb(255,225,0)",
				1.0: "rgb(255,0,0)"
			},
			radius: 20, //每个数据点将具有的半径
			maxOpacity: 0.8, //热力图中最高值的最大不透明度。(如果设置了不透明度,将被覆盖)
			minOpacity: 0.1, //热力图中最低值的最小不透明度(如果设置了不透明度,将被覆盖)
			blur: 0.85, //值越大,渐变越平滑,外圆占比越大。
			height: 1000, //三维热力图元最下端与球面的距离
			extrudedHeight: 50000, //三维热力图元最上端与球面的距离
			granularity: 8.726646259971648e-7, //该值决定了图元顶点的数量。值越小,顶点数量越多,则渲染越平滑,相应地帧数会降低。反之,值越大,顶点数量越少,则渲染越不平滑,相应地帧数也会上升。
		}
	});

	//添加到地图/地球上
	viewer.effectLayers.add(heatMapEffectLayer);

	// heatMapEffectLayer.setData(ztb_geojson.features);
	heatMapEffectLayer.setData([{
		"type": "Feature",
		"geometry": {
			"type": "Point",
			"coordinates": [116.41102505283855, 39.913896746674816]
		},
		"properties": {
			"县": "东城区",
			"统计数": "2",
			"RN": "1"
		}
	}, {
		"type": "Feature",
		"geometry": {
			"type": "Point",
			"coordinates": [125.26612659791823, 43.681044366244265]
		},
		"properties": {
			"县": "朝阳区",
			"统计数": "4",
			"RN": "2"
		}
	}, {
		"type": "Feature",
		"geometry": {
			"type": "Point",
			"coordinates": [115.24119162138823, 39.31003069890482]
		},
		"properties": {
			"县": "易县",
			"统计数": "1",
			"RN": "77"
		}
	}]);

	viewer.on('click', function(e) {
		if (e.originalLayer === heatMapEffectLayer) {
			// debugger;
			let {
				features
			} = e;
			alert("热力图数据数量:" + features.length);
		}
	});

//三维热力图从服务加载数据示例:

//wfs服务相关信息
var wfsService = {
		url: "http://192.168.100.231:8889/zjeffecttest/wfs",
		featureType: "effectPoint"
};

//使用数据源数据	
var dataSource = new Cesium.GeoWFSDataSource({
	  url: wfsService.url,
	  featureType: wfsService.featureType,
});

var heatMapEffectLayer = new Cesium.GeoHeatMapEffectLayer({
	  dataSource: dataSource,
	  effectTypeMapField: 'effectType', //特效类型映射要素字段名
	  valueMapField: 'length',
	  heatmap3dOptions: {
		gradient: { //渐变颜色描述
			0.25: "rgb(0,0,225)",
			0.55: "rgb(0,225,0)",
			0.85: "rgb(255,225,0)",
			1.0: "rgb(255,0,0)"
		},
		radius: 60,//每个数据点将具有的半径
		maxOpacity: 0.8, //热力图中最高值的最大不透明度。(如果设置了不透明度,将被覆盖)
		minOpacity: 0.1, //热力图中最低值的最小不透明度(如果设置了不透明度,将被覆盖)
		blur: 0.85, //值越大,渐变越平滑,外圆占比越大。
		height: 30, //三维热力图元最下端与球面的距离
		extrudedHeight: 60, //三维热力图元最上端与球面的距离
		granularity: 8.726646259971648e-8,//该值决定了图元顶点的数量。值越小,顶点数量越多,则渲染越平滑,相应地帧数会降低。反之,值越大,顶点数量越少,则渲染越不平滑,相应地帧数也会上升。
					
	 }
});

//添加到地图/地球上
viewer.effectLayers.add(heatMapEffectLayer);

//数据源加载数据
dataSource.load(function(){
	 
	 let dest = Cesium.Cartesian3.fromDegrees(121.4986249488635,31.21638927817536,1000);
	 //
	 viewer.camera.setView({
	 	destination: dest,
	 	orientation: {
	 		heading: 6.283185307179582,
	 		pitch: -1.5692226099725621,
	 		roll: 0
	 	}
	 });
});	
Demo:

Extends

Methods

addTo(map)

绑定到三维地图
Name Type Description
map viewer
Inherited From:

destroy()

销毁图层对象
Inherited From:

getData()

获取图层数据
Inherited From:

getDataSource()

获取数据源
Inherited From:

hide()

隐藏图层

pickFeatures(pickedFeatures, windowPosition)Object

拾取图层中的要素
Name Type Description
pickedFeatures Array 场景中被拾取的对象集合,需要在图层自己内部判断识别出属于自己的,并挂接上图层的属性信息
windowPosition Cartesian2 画布的二维坐标
Returns:
返回固定形态的结构数据
Example:
//返回结构参考样例
{
			eventType: ScreenSpaceEventType.LEFT_CLICK,
			originalLayer: GeoODFaceEffectLayer
			param:{
				info: pickedFeature,
				pickedInfos: pickedFeatureList
			}
		}

remove()

将图层从视图移除

removeDataSource()

移除数据源
Inherited From:

setData(features)

设置图层相关数据
Name Type Description
features Array.<Object> geojson要素数组

setDataSource(dataSource)

设置数据源
Name Type Description
dataSource GeoDataSource
Inherited From:

show()

显示图层