| | |
| | | <script setup> |
| | | import HomeRight from './components/HomeRight/HomeRight.vue'; |
| | | import HomeLeft from '@/views/Home/components/HomeLeft/HomeLeft.vue'; |
| | | import { getAggregation } from '@/views/Home/aggregation'; |
| | | import SearchBox from '@/views/Home/SearchBox.vue'; |
| | | import jiangxi from '@/assets/geojson/jiangxi.json'; |
| | | import nanchang from '@/assets/geojson/nanchang.json'; |
| | | import jiangxishi from '@/assets/geojson/jiangxishi.json'; |
| | | import zg from '@/assets/geojson/zg.json'; |
| | | import * as Cesium from 'cesium'; |
| | | import data1 from '@/assets/images/home/homeRight/data1.png'; |
| | | import data2 from '@/assets/images/home/homeRight/data2.png'; |
| | | |
| | | const list = [ |
| | | { name: '县', value: [0,48651], gJson: null }, |
| | |
| | | |
| | | const determineScaling = () => { |
| | | let height = viewer.camera.positionCartographic.height; |
| | | console.log('缩放结束,高度为:', height); |
| | | // 根据高度展示对应的 gJson |
| | | for (let item of list) { |
| | | // if (height < item.value) { |
| | |
| | | active.value = item.name; |
| | | if (item.gJson) { |
| | | aggregation(item); |
| | | }else{ |
| | | for (let i = 0; i < 50; i++) { |
| | | viewer.entities.add({ |
| | | position: Cesium.Cartesian3.fromDegrees( |
| | | 115.89 + Math.random() * 0.2, |
| | | 28.68 + Math.random() * 0.2 |
| | | ), |
| | | label: { |
| | | // 随机整数 |
| | | text: Math.floor(Math.random() * 100)+'号机巢', |
| | | font: '14pt monospace', |
| | | fillColor: Cesium.Color.WHITE, |
| | | outlineColor: Cesium.Color.BLACK, |
| | | outlineWidth: 2, |
| | | style: Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, |
| | | pixelOffset: new Cesium.Cartesian2(0, -9), |
| | | }, |
| | | billboard: { |
| | | image: data1, |
| | | width: 24, |
| | | height: 24, |
| | | }, |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, |
| | | pixelOffset: new Cesium.Cartesian2(0, -9), |
| | | }, |
| | | billboard: { |
| | | image: data2, |
| | | width: 24, |
| | | height: 24, |
| | | }, |
| | | }); |
| | | }); |
| | | // 加载新的 GeoJSON 数据 |
| | |
| | | entity.polygon.material = new Cesium.ColorMaterialProperty( |
| | | Cesium.Color.YELLOW.withAlpha(0) // 透明填充 |
| | | ); |
| | | entity.polygon.outline = true; // 显示边框 |
| | | entity.polygon.outlineColor = Cesium.Color.YELLOW; // 黑色边框 |
| | | entity.polygon.outline = new Cesium.ConstantProperty(true); // 显示边框 |
| | | entity.polygon.outlineColor = new Cesium.ConstantProperty(Cesium.Color.YELLOW); // 黑色边框 |
| | | }); |
| | | }); |
| | | }; |