您好,您可以通过将每个面作为单独的 Entity 添加
const features = queryResult.features; // 假设查询结果是一个包含面数据的数组
for (let i = 0; i < features.length; i++) {
const feature = features[i];
const entity = new Cesium.Entity({
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray(feature.geometry.coordinates),
material: Cesium.Color.fromCssColorString('#ff0000').withAlpha(0.5),
},
properties: {
id: feature.properties.id,
name: feature.properties.name,
},
});
viewer.entities.add(entity);
}
也可以变成一个图层添加的
const features = queryResult.features; // 假设查询结果是一个包含面数据的数组
const geoJson = {
type: 'FeatureCollection',
features: features.map((feature) => ({
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [feature.geometry.coordinates],
},
properties: {
id: feature.properties.id,
name: feature.properties.name,
},
})),
};
const dataSource = Cesium.GeoJsonDataSource.load(geoJson);
viewer.dataSources.add(dataSource);