| | |
| | | // 获取 GeoJSON 中的 Polygon feature |
| | | return dataSourcePromise.then(function (dataSource) { |
| | | viewer.dataSources.add(dataSource); |
| | | console.log("GeoJSON data loaded:", dataSource); |
| | | // console.log("GeoJSON data loaded:", dataSource); |
| | | areaDataSource.push(dataSource); |
| | | |
| | | const polygonEntity = dataSource.entities.values; |
| | | console.log("Entities in dataSource:", polygonEntity); |
| | | // console.log("Entities in dataSource:", polygonEntity); |
| | | |
| | | // 初始化效果 |
| | | applyPolygonEffects(polygonEntity, color); |
| | |
| | | } |
| | | |
| | | function applyPolygonEffects(entities, color) { |
| | | console.log("Applying polygon effects..."); |
| | | // console.log("Applying polygon effects..."); |
| | | entities.forEach(entity => { |
| | | entity.polygon.heightReference = Cesium.HeightReference.NONE; |
| | | entity.polygon.material = new Cesium.ColorMaterialProperty(color); // 设置填充颜色 |
| | |
| | | if (!viewer.entities.getById(entity.id)) { |
| | | viewer.entities.add(entity); |
| | | } |
| | | console.log("Effect applied to entity:", entity.id); |
| | | // console.log("Effect applied to entity:", entity.id); |
| | | }); |
| | | } |
| | | |