热力图特效图层类
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
参数选项:
|
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
绑定到三维地图
Name | Type | Description |
---|---|---|
map |
viewer |
- Inherited From:
销毁图层对象
- Inherited From:
获取图层数据
- Inherited From:
获取数据源
- Inherited From:
隐藏图层
拾取图层中的要素
Name | Type | Description |
---|---|---|
pickedFeatures |
Array | 场景中被拾取的对象集合,需要在图层自己内部判断识别出属于自己的,并挂接上图层的属性信息 |
windowPosition |
Cartesian2 | 画布的二维坐标 |
Returns:
返回固定形态的结构数据
Example:
//返回结构参考样例
{
eventType: ScreenSpaceEventType.LEFT_CLICK,
originalLayer: GeoODFaceEffectLayer
param:{
info: pickedFeature,
pickedInfos: pickedFeatureList
}
}
将图层从视图移除
移除数据源
- Inherited From:
设置图层相关数据
Name | Type | Description |
---|---|---|
features |
Array.<Object> | geojson要素数组 |
设置数据源
Name | Type | Description |
---|---|---|
dataSource |
GeoDataSource |
- Inherited From:
显示图层