cesium-geojson和kml
2022-01-21 本文已影响0人
姜治宇
let viewer = new Cesium.Viewer('cesiumContainer');
//geojson
let geoProm = Cesium.GeoJsonDataSource.load('吉林省.geojson', {
stroke: Cesium.Color.YELLOW,
fill: Cesium.Color.RED,
strokeWidth: 3,
});
geoProm.then(dataSource=>{
viewer.dataSources.add(dataSource);
let entities = dataSource.entities.values;
console.log(entities);
for (let i = 0; i < entities.length; i++) {
let entity = entities[i];
let color = Cesium.Color.fromRandom({
alpha: 1.0
});
entity.polygon.material = color;//随机颜色
entity.polygon.outline = false; //去掉边框
entity.polygon.extrudedHeight =5000.0;//带高度
}
});
//kml
let kmlProm = Cesium.KmlDataSource.load('demo.kml');
kmlProm.then(dataSource=>{
viewer.dataSources.add(dataSource);
});
img.gif