| | |
| | | /** |
| | | * 机巢聚合功能 |
| | | */ |
| | | |
| | | let arrColor = ["rgb(15,176,255)", "rgb(18,76,154)", "#40C4E4", "#42B2BE", "rgb(51,176,204)", "#8CB7E5", "rgb(0,244,188)", "#139FF0"] |
| | | |
| | | let index = 0 |
| | | function getColor () { |
| | | return arrColor[++index % arrColor.length] |
| | | } |
| | | |
| | | export const useMapAggregation = type => { |
| | | const { flyTo } = cesiumOperation() |
| | | |
| | |
| | | entities.forEach((entity, index) => { |
| | | // 创建独立折线作为轮廓 |
| | | const positions = entity.polygon.hierarchy.getValue().positions |
| | | viewer.entities.add({ |
| | | const randomInt = Math.floor(Math.random() * 5) + 1 |
| | | |
| | | let polygon = {} |
| | | |
| | | if (item.name == '县') { |
| | | let material = new PolyGradientMaterial({ |
| | | color: Cesium.Color.fromCssColorString(arrColor[randomInt]), |
| | | opacity: 0.7, |
| | | alphaPower: 1.3 |
| | | }) |
| | | |
| | | entity.polygon.extrudedHeight = (entity.properties.childrenNum._value || 1) * 500 |
| | | |
| | | entity.polygon.material = material |
| | | |
| | | polygon = entity.polygon |
| | | entity.polygon.outline = false // 显示边框 |
| | | } |
| | | |
| | | let curEntity = viewer.entities.add({ |
| | | id: `aggregation-outline-${index}`, |
| | | polyline: { |
| | | positions: positions, |
| | |
| | | color: Cesium.Color.AQUA, |
| | | }), |
| | | }, |
| | | |
| | | polygon |
| | | }) |
| | | |
| | | item.name == '县' && viewer.flyTo(curEntity, { |
| | | offset: new Cesium.HeadingPitchRange(0, Cesium.Math.toRadians(-60), 0), |
| | | duration: 0.5, |
| | | }) |
| | | }) |
| | | }) |
| | |
| | | }) |
| | | }) |
| | | |
| | | let arrColor = ["rgb(15,176,255)", "rgb(18,76,154)", "#40C4E4", "#42B2BE", "rgb(51,176,204)", "#8CB7E5", "rgb(0,244,188)", "#139FF0"] |
| | | |
| | | let index = 0 |
| | | function getColor () { |
| | | return arrColor[++index % arrColor.length] |
| | | } |
| | | |
| | | // 加载边界 |
| | | Cesium.GeoJsonDataSource.load(item.gJson).then(dataSource => { |
| | | console.log(dataSource, item.gJson) |
| | | |
| | | viewer.dataSources.add(dataSource) |
| | | item.BJDataSource = dataSource // 保存数据源以便后续删除 |
| | | // 获取数据源中的实体 |
| | |
| | | } |
| | | // 移除弹框标签 |
| | | const removeLabel = () => { |
| | | viewer.scene.postRender.removeEventListener(labelBoxRender) |
| | | viewer?.scene.postRender.removeEventListener(labelBoxRender) |
| | | removeDom() |
| | | } |
| | | |