suerprisePlus
2024-07-16 6069325e1a37cf0462afda1627d4c660735dc57e
src/assets/js/map/mapJsonLayer.js
@@ -20,7 +20,8 @@
  targetList: [],
  linePath: null,
  richTextPoint1: null,
  wfsLayer:null,
  wfsLayer: null,
  dataSource: null,
  init(url) {
    this.url = url;
    this.getJsonLayer();
@@ -117,7 +118,7 @@
    });
  },
  setQueryTF2(name) {
    // const obj = "weaponname like '%" + name + "%'" + "";
    //  const obj = "weaponname like '%堤丰系统%'" + "";
    const filed = this.getPublickey(name);
    const layer = modelLayer.layers.filter((item) => {
      if (item.name == "武器点") {
@@ -134,12 +135,12 @@
      dbid: modelLayer.dbid,
      where: filed
    }).then((response) => {
      if (response.code != 200) return;
      const geom = response.data.items[0];
      const position = [geom._x, geom._y, 0];
      const cylinder = {
        radius: 1500, //半径
        radius: 400000, //半径
        angle: 30, //扫描角度(可选)
        speed: 5, //倍速(可选)
        stackPartitions: 80, //横向网格数(可选)
@@ -150,7 +151,15 @@
        position,
        cylinder
      );
      // Viewer.zoomTo(this.rectangularSensor.item);
      earthCtrl.camera.flyTo(
        113.00849464328284,
        10.437567580726105,
        1101300.7027243855,
        57, -45, 0, 2
        );
    });
  },
  setQueryByFiled(name, color) {
@@ -233,7 +242,11 @@
  },
  setTitleSetRest() {
    this.targetList = [];
    if(this.wfsLayer){
    if (this.dataSource) {
      Viewer.dataSources.remove(this.dataSource);
      this.dataSource = null
    }
    if (this.wfsLayer) {
      // this.wfsLayer.removeFromMap();
      this.wfsLayer.destroy();
    }
@@ -289,7 +302,7 @@
    if (objItem.length <= 0) return;
    var tileset = objItem[0].layer;
    const list = this.targetList;
    tileset.style = new Cesium.Cesium3DTileStyle({
      color: {
        evaluateColor: (feature) => {
@@ -308,13 +321,66 @@
      }
    });
  },
  setAddWfsLayer(){
    this.wfsLayer = earthCtrl.factory.createWfsLayer('polygon', {
      urls: 'https://cim.smartearth.cn/SEserver/wfsserver/SubicBayWeapon_wfs',
      layer: 'weapons',
      outlineColor:'#ff0000',
      alpha:0,
    })
  setAddWfsLayer() {
    this.wfsLayer = earthCtrl.factory.createWfsLayer("polygon", {
      urls: "https://cim.smartearth.cn/SEserver/wfsserver/SubicBayWeapon_wfs",
      layer: "weapons",
      outlineColor: "#ff0000",
      alpha: 0
    });
  },
  setAddWfsJson() {
    const url = this.getQueryUrl("SubicBayWeapon_wfs", "weapons");
    const that = this;
    Cesium.GeoJsonDataSource.load(url, {
      fill: Cesium.Color.fromCssColorString("#FFFFFF00"),
      stroke: Cesium.Color.fromCssColorString("#FFFFFF00"), //多边形或线的颜色
      strokeWidth: 0 //多边形或线 宽度
    }).then((dataSource) => {
      that.dataSource = dataSource;
      const entities = that.dataSource.entities.values;
      entities.map((item) => {
        item.polygon._material.color =
          Cesium.Color.fromCssColorString("#FFFFFF00");
        item.polygon.heightReference =
          Cesium.HeightReference.RELATIVE_TO_GROUND; // 贴地
        item.polygon.height = 0; // 距地高度0米
        var polyPositions = item.polygon.hierarchy.getValue().positions;
        var polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center; //中心点
        polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter);
        item.position = polyCenter;
        let positions = item.polygon.hierarchy._value.positions;
        // 设置面轮廓
        item.polyline = new Cesium.PolylineGraphics({
          positions: positions,
          clampToGround: true, // 贴地
          width: 5,
          material: Cesium.Color.fromCssColorString("#FFA500")
        });
        const label_name = item.name ? item.name : "";
        item.label = {
          text: label_name,
          font: "500 16x sans-serif",
          style: Cesium.LabelStyle.FILL_AND_OUTLINE, // 字体样式
          fillColor: new Cesium.Color.fromCssColorString("#FFFFFF"),
          outlineWidth: 1, // 字体外圈线宽度(同样也有颜色可设置)
          outlineColor: new Cesium.Color.fromCssColorString("#FFFFFF"),
          verticalOrigin: Cesium.VerticalOrigin.BASELINE, // 垂直位置
          pixelOffset: new Cesium.Cartesian2(0, 0), // 中心位置
          disableDepthTestDistance: Number.POSITIVE_INFINITY,
          distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
            500.0,
            3000.0
          )
          // showBackground:true,
          // backgroundColor: new Cesium.Color(26 / 255, 196 / 255, 228 / 255, 1.0) //背景顔色
        };
      });
      Viewer.dataSources.add(that.dataSource);
    });
  },
  getTileSet() {
    var objItem = mapServer.listData.filter((item) => {
@@ -463,7 +529,7 @@
      width: 3, //线宽(可选)
      color: "#00ffff", //线颜色(可选),
      LightSpot: true, //是否使用光点效果(可选)
      LightSpotColor: "#ffffff" ,//光点颜色(可选)
      LightSpotColor: "#ffffff", //光点颜色(可选)
      height: 100
    };
    this.linePath = earthCtrl.factory.createTrailLinePath(