yxl
2025-01-02 c0ff61d066a9f65aa0cdbeb1e10a249763f1e966
src/assets/js/map/mapView.js
@@ -16,7 +16,7 @@
      // 隐藏默认底图
      defaultImagery: false,
      // 隐藏logo
      printLog: false
      printLog: false,
      // maxViewHeight: 1200000
      // sceneMode: SmartEarth.Cesium.SceneMode.SCENE2D
    });
@@ -31,7 +31,7 @@
        // 这里可以获取到点击的实体或其他对象
        var featureId = pickedObject.getProperty("id");
        console.log(featureId);
        // pickedObject.color = Cesium.Color.RED;
        console.log("点击的对象:", pickedObject);
      }
@@ -66,9 +66,9 @@
      0.001313831409284339,
      2
    );
// setTimeout(() => {
//   mapModel.init();
// }, 5000);
    // setTimeout(() => {
    //   mapModel.init();
    // }, 5000);
    // mapServer.addServer({
    //   sourceType: "Tileset",
    //   url: "http://103.135.160.14:9038/gisserver/c3dserver/JiashanBase/tileset.json",
@@ -108,6 +108,14 @@
    //   }
    // });
    // mapInfo.setEntityQueryInput();
    // this.addWfsLayer()
    // this.addRaderLayer()
    // this.addModel()
    // this.addTetrahedron({
    //   lon: 121.614202387521061,
    //   lat: 23.990136825668284,
    //   alt: 150
    // })
  },
  addTetrahedron(res) {
    earthCtrl.factory.addTetrahedron({
@@ -213,6 +221,95 @@
      url: "https://rt0.map.gtimg.com/tile?z={z}&x={x}&y={reverseY}&styleid=4&scene=0",
      tilingScheme: earthCtrl.core.getOffsetTilingScheme() // 偏移纠正
    });
  },
  // 添加wfs
  addWfsLayer() {
    earthCtrl.viewer.camera.flyTo({
      destination: {
        x: -3475710.5684351875,
        y: 5625834.799523204,
        z: 2729961.751894543,
      },
      orientation: {
        heading: 5.73978482494632,
        pitch: -1.2817819264676036,
        roll: 6.282989918773924,
      },
    });
    earthCtrl.factory.createWfsLayer('point', {
      urls: 'https://cim.smartearth.cn/geoserver/JiaShanBase/ows',
      layer: 'JiaShanBase:RadarSpot',
      text: '[JiaShanBase:Type]',
      color: '#de3',
      disableDepthTestDistance: Infinity
    })
    earthCtrl.factory.createWfsLayer('polyline', {
      urls: 'https://cim.smartearth.cn/geoserver/JiaShanBase/ows',
      layer: 'JiaShanBase:RadarL',
      width: 1.5,
      color: '#87CEFA',
    })
    earthCtrl.factory.createWfsLayer('polyline', {
      urls: 'https://cim.smartearth.cn/geoserver/JiaShanBase/ows',
      layer: 'JiaShanBase:RadarM',
      width: 1.5,
      color: '#de3',
    })
    earthCtrl.factory.createWfsLayer('polyline', {
      urls: 'https://cim.smartearth.cn/geoserver/JiaShanBase/ows',
      layer: 'JiaShanBase:RadarS',
      width: 1.5,
      color: '#FF0000',
    })
  },
  addRaderLayer() {
    //雷达遮罩扫描(自定义)
    const option = {
      radius: 1000,  //半径
      yaw: 0,  //雷达方向(可选)
      angle: 120,  //雷达夹角(可选)
      scanAngle: 30,  //扫描夹角(可选)
      speed: 5,  //倍速(可选)
      maxLat: 90,  //下维度(可选)
      minLat: 45,  //上维度(可选)
      stackPartitions: 40,  //横向网格数(可选)
      slicePartitions: 80,  //纵向网格数(可选)
      //color: 'rgba(255,255,255,0.5)',  //雷达遮罩颜色(可选)
      //outlineColor: 'rgba(255,255,255,0.5)',  //雷达遮罩边框线颜色(可选)
      //scanColor: 'rgba(255,0,0,0.5)',   //扫描颜色(可选)
    };
    const position1 = [121.614202387521061, 23.990136825668284, 0];
    // 雷达遮罩
    earthCtrl.factory.createRadarMaskScan('雷达遮罩扫描1', position1, option)
  },
  addModel() {
    const entity = earthCtrl.viewer.entities.add({
      position: SmartEarth.Cesium.Cartesian3.fromDegrees(
        121.614202387521061,
        23.990136825668284,
        0
      ),
      model: {
        uri: '/gltf/tank.glb',
        scale: 15,
        heightReference: SmartEarth.Cesium.HeightReference.CLAMP_TO_GROUND,
        disableDepthTestDistance: Number.POSITIVE_INFINITY // 禁用深度测试
      },
      label: {
        show: true,
        text: '经度:121.6142023,纬度:23.9901368',
        color: SmartEarth.Cesium.Color.fromCssColorString("#fff"),
        font: "normal 14px MicroSoft YaHei",
        showBackground: true,
        outlineColor: SmartEarth.Cesium.Color.WHITE,
        pixelOffset: new SmartEarth.Cesium.Cartesian2(10, -30),
        horizontalOrigin: SmartEarth.Cesium.HorizontalOrigin.CENTER,
        verticalOrigin: SmartEarth.Cesium.VerticalOrigin.BOTTOM,
        heightReference: SmartEarth.Cesium.HeightReference.CLAMP_TO_GROUND,
      },
    });
  }
};
export default mapViewer;