|
@@ -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();
|
|
|
+
|
|
|
+ });
|
|
|
|
|
|
|
|
|
}, //生命周期 - 挂在完成
|