zpf 1 年間 前
コミット
a72b940bcb

+ 8 - 0
src/api/cockpit.js

@@ -34,4 +34,12 @@ export function cockpitInfo(params) {
     method: 'get',
     params
   })
+}
+
+export function getGeoJson(url) {
+  console.log(111);
+  return request({
+    url: url,
+    method: 'get',
+  })
 }

+ 0 - 1
src/views/cockpitNew1/tdsy.vue

@@ -208,7 +208,6 @@ export default {
                                     color: '#fff'
                                 },
                                 formatter: function (params) {
-                                    console.log(params)
                                     // return '{point|}{white|' + params.name + '}{blue|' + params.percent + '%}\n{yellow|' + params.value + '}';
                                     return params.value + '%';
 

+ 82 - 2
src/views/viewer1.vue

@@ -21,8 +21,8 @@ import TDSY from './cockpitNew1/tdsy';
 import GDBH from './cockpitNew1/gdbh';
 import STXF from './cockpitNew1/stxf';
 import WPJG from './cockpitNew1/wpjg';
-import { cockpitInfo } from '@/api/cockpit'
-
+import { cockpitInfo, getGeoJson } from '@/api/cockpit'
+// import s from "./"
 export default {
     components: { JSYD, TDSC, HYSY, TDSY, GDBH, STXF, WPJG },
     data() {
@@ -39,6 +39,58 @@ export default {
         switch() {
             this.flag = !this.flag;
 
+        },
+        pick_xzqh() {
+            const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
+            handler.setInputAction(event => {
+                let pickObj = viewer.scene.pick(event.position);
+                var position = viewer.scene.pickPosition(event.position);
+
+                if (!position)//点击到地球之外
+                    return false;
+                var cartographic = Cesium.Cartographic.fromCartesian(position);
+
+
+                let longitude = Cesium.Math.toDegrees(cartographic.longitude);
+                let latitude = Cesium.Math.toDegrees(cartographic.latitude);
+                let height = cartographic.height;
+                let heading = viewer.scene.camera.heading;
+                let pitch = viewer.scene.camera.pitch;
+                if (!pickObj)//未获取实体
+                    return false;
+                // console.log(longitude, latitude, height);
+                if (!pickObj) {
+                    return false;
+                }
+
+                if (!position) {
+                    position = Cesium.Cartesian3.fromDegrees(0, 0, 0);
+                }
+
+
+                if (Cesium.defined(pickObj)) {
+
+
+
+                    if (pickObj.id && pickObj.id instanceof Cesium.Entity) {//点击entity
+
+                        console.log('点击entity');
+                        if (pickObj.id.properties.hasProperty('name')) {
+                            const name = pickObj.id.properties.name.getValue();
+                            const address = pickObj.id.properties.obj.getValue();
+                            console.log(name, address);
+
+                        }
+
+                    }
+
+
+
+
+                } else {
+                }
+
+            }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
         }
     },
     beforeCreate() { }, //生命周期 - 创建之前
@@ -56,6 +108,34 @@ export default {
 
         // console.log(data, "asda");
         // console.log(data1, "asda");
+        // 三亚行政区划加载
+        // 加载公园面状文件并拉伸一定高度
+
+
+        let xzqh = await getGeoJson('');
+        console.log(xzqh, "xzqh");
+
+        // Cesium.GeoJsonDataSource.load('https://geo.datav.aliyun.com/areas_v3/bound/460200_full.json').then(function (dataSource) {
+        //     viewer.dataSources.add(dataSource);
+        //     let entities = dataSource.entities.values;
+        //     for (let i = 0; i < entities.length; i++) {
+        //         console.log('entities: ', entities);
+        //         let entity = entities[i];
+        //         entity.polygon.material = Cesium.Color.fromCssColorString("RGBA(24, 100, 166, 0.7)");
+        //         entity.polygon.outline = false;
+        //         // 将高度拉伸至35米
+        //         entity.polygon.extrudedHeight = 450;
+        //         entity.polygon.height = 100;
+        //         entity.properties = {
+        //             'name': "qwe",
+
+        //         };
+        //     }
+        // });
+        this.$nextTick((res) => {
+            this.pick_xzqh();
+
+        });
 
 
     }, //生命周期 - 挂在完成

ファイルの差分が大きいため隠しています
+ 0 - 0
static/data/460200_full.json


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません