Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
参数选项:
|
Example:
//直接添加柱图图层
var data = [
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [114.25,30.54]
},
properties: {
name:"武汉",
data:[
{value:300000, name:"老年"},
{value:600000, name:"中年},
{value:500000,name:" 青年}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [116.39127,39.9071]
},
properties: {
name:"北京",
data:[
{value:200000, name:"老年"},
{value:500000, name:"中年"},
{value:400000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [104.01,30.86]
},
properties: {
name:"成都",
data:[
{value:1300000, name:"老年"},
{value:400000, name:"中年"},
{value:500000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [123.48,41.85]
},
properties: {
name:"沈阳",
data:[
{value:200000, name:"老年"},
{value:1500000, name:"中年"},
{value:400000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [113.29,23.22]
},
properties: {
name:"广州",
data:[
{value:200000, name:"老年"},
{value:500000, name:"中年"},
{value:1400000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [121.20,31.61]
},
properties: {
name:"上海",
data:[
{value:800000, name:"老年"},
{value:1800000, name:"中年"},
{value:400000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [91.05,29.72]
},
properties: {
name:"拉萨",
data:[
{value:600000, name:"老年"},
{value:100000, name:"中年"},
{value:2000000,name:" 青年"}
]
}
}
];
var geoBarLayer = new Cesium.GeoBarLayer({
viewer: viewer,
anchor:'center',
});
geoBarLayer.addTo(viewer);
// 或者
// viewer.effectLayers.add(geoBarLayer);
geoBarLayer.setData(data);
//使用echarts添加饼图图层
var data = [
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [114.25,30.54]
},
properties: {
name:"武汉",
data:[
{value:300000, name:"老年"},
{value:600000, name:"中年},
{value:500000,name:" 青年}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [116.39127,39.9071]
},
properties: {
name:"北京",
data:[
{value:200000, name:"老年"},
{value:500000, name:"中年"},
{value:400000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [104.01,30.86]
},
properties: {
name:"成都",
data:[
{value:1300000, name:"老年"},
{value:400000, name:"中年"},
{value:500000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [123.48,41.85]
},
properties: {
name:"沈阳",
data:[
{value:200000, name:"老年"},
{value:1500000, name:"中年"},
{value:400000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [113.29,23.22]
},
properties: {
name:"广州",
data:[
{value:200000, name:"老年"},
{value:500000, name:"中年"},
{value:1400000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [121.20,31.61]
},
properties: {
name:"上海",
data:[
{value:800000, name:"老年"},
{value:1800000, name:"中年"},
{value:400000,name:" 青年"}
]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [91.05,29.72]
},
properties: {
name:"拉萨",
data:[
{value:600000, name:"老年"},
{value:100000, name:"中年"},
{value:2000000,name:" 青年"}
]
}
}
];
var color = ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'];
function myRenderer(feature, features, target ) {
let canvasDom = document.createElement('div');
canvasDom.style.width = "200px";
canvasDom.style.height = "200px";
let myChart = echarts.init(canvasDom);
var option = {
color: color,
tooltip: {
trigger: 'item',
formatter: "{b}: {d}%",
},
series: [{
type:'bar',
label: {
normal:{
show:false
},
},
center:['50%', '50%'],
radius: [0,50],
data:feature.properties.data,
}]
};
option && myChart.setOption(option);
return canvasDom;
}
var geoBarLayer = new Cesium.GeoBarLayer({
viewer: viewer,
featureRenderer: myRenderer
});
geoBarLayer.addTo(viewer);
geoBarLayer.setData(data);
Extends
Methods
添加图例
绑定到三维地图
Name | Type | Description |
---|---|---|
map |
viewer |
- Inherited From:
销毁图层对象
获得图层数据
获取图层数据源
隐藏图层
拾取要素
Name | Type | Description |
---|---|---|
pickedFeatures |
Array | 场景中被拾取的对象集合,需要在图层自己内部判断识别出属于自己的,并挂接上图层的属性信息 |
windowPosition |
Cartesian2 | 画布的二维坐标 |
Returns:
返回固定形态的结构数据
Example:
//返回结构参考样例
{
eventType: ScreenSpaceEventType.LEFT_CLICK,
originalLayer: GeoBarLayer,
feature: popup._feature
}
将图层从视图中移除
移除图层数据源
移除图例
渲染图层
设置图层的数据
Name | Type | Description |
---|---|---|
data |
Array | 要素集合,此处必须是点要素集合。例如[{type: 'Feature',geometry: {type: 'Point',coordinates: [117.177, 34.281, 0]}}, {type: 'Feature',geometry: {type: 'Point',coordinates: [117.177, 34.281, 300]}}...], 如果坐标没有指定高程值,则默认是0 |
设置图层数据源
Name | Type | Description |
---|---|---|
dataSource |
GeoDataSource |
设置要素的渲染器,是一个函数,具体见构造函数的描述
Name | Type | Description |
---|---|---|
featureRendererCallBack |
function |
显示图层