Pārlūkot izejas kodu

加载离线数据

zpf 1 gadu atpakaļ
vecāks
revīzija
676c99f312
2 mainītis faili ar 20 papildinājumiem un 33 dzēšanām
  1. 0 8
      src/api/cockpit.js
  2. 20 25
      src/views/viewer1.vue

+ 0 - 8
src/api/cockpit.js

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

+ 20 - 25
src/views/viewer1.vue

@@ -21,7 +21,7 @@ import TDSY from './cockpitNew1/tdsy';
 import GDBH from './cockpitNew1/gdbh';
 import STXF from './cockpitNew1/stxf';
 import WPJG from './cockpitNew1/wpjg';
-import { cockpitInfo, getGeoJson } from '@/api/cockpit'
+import { cockpitInfo } from '@/api/cockpit'
 // import s from "./"
 export default {
     components: { JSYD, TDSC, HYSY, TDSY, GDBH, STXF, WPJG },
@@ -77,7 +77,7 @@ export default {
                         console.log('点击entity');
                         if (pickObj.id.properties.hasProperty('name')) {
                             const name = pickObj.id.properties.name.getValue();
-                            const address = pickObj.id.properties.obj.getValue();
+                            const address = pickObj.id.properties.adcode.getValue();
                             console.log(name, address);
 
                         }
@@ -109,29 +109,24 @@ 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",
-
-        //         };
-        //     }
-        // });
+
+        Cesium.GeoJsonDataSource.load("../../static/data/460200_full.json").then(function (dataSource) {
+            viewer.dataSources.add(dataSource);
+            let entities = dataSource.entities.values;
+            for (let i = 0; i < entities.length; i++) {
+                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': entity.properties._name._value,
+                    'adcode': entity.properties.adcode._value,
+
+                };
+            }
+        });
         this.$nextTick((res) => {
             this.pick_xzqh();