Newer
Older
KaiFengPC / src / views / sponeScreen / gisMF / newfiberVectorLayer.js
@jimengfei jimengfei on 26 Jun 4 KB updata
export default class newfiberVectorLayer {
  //添加图标标注点
  static addGeojsonPoint(newfiberMap, geojson, icon_url, newfiberId) {
    geojson.features.forEach(
      feature =>
        (feature.properties = Object.assign(feature.properties, {
          style_: {
            type: NewFiberMap.Enum.VectorType.ICON,
            options: {
              show: true,
              url: icon_url,
              width: 30,
              height: 30,
              pixelOffset: [0, 0],
              distanceDisplayCondition: [Number.MIN_VALUE, 7000000],
            },
            name: feature.properties.name || feature.properties.pumpName,
            id: newfiberId,
            labelOptions: {
              font: '16px PingFang SC',
              color: 'rgba(175, 50, 50,1)',
              pixelOffset: [0, 0],
              backgroundColor: 'rgba(0,0,0,1)',
              showBackground: false,
              outlineColor: 'rgba(0, 0, 0, 0.8)',
              outlineWidth: 6,
              style: Cesium.LabelStyle.FILL_AND_OUTLINE,
              distanceDisplayCondition: [Number.MIN_VALUE, 7000000],
            },
          },
        }))
    );
    if (newfiberMap.getLayers(newfiberId).length > 0) {
      return;
    } else {
      newfiberMap.geojsonToMap(geojson);
    }
  }
  //添加geojson面
  static addGeojsonPolygon(newfiberMap, geojson, newfiberId) {
    geojson.features.forEach(
      feature =>
        (feature.properties = Object.assign(feature.properties, {
          style_: {
            type: NewFiberMap.Enum.VectorType.POLYGON,
            options: {
              show: true,
              material: !!feature.properties.fillcolor ? feature.properties.fillcolor : 'rgba(154,104,171,0.4)',
              outline: false,
              // outlineColorBottom: !!feature.properties.outcolor ? feature.properties.outcolor : 'rgba(189,127,171,0.75)',
              // outlineWidthBottom: 2,
            },
            name: feature.properties.name != ' ' ? feature.properties.name : null,
            id: newfiberId,
            labelOptions: {
              font: '20px PingFang SC',
              color: 'rgba(16, 117, 224, 1)',
              pixelOffset: [0, 0],
              backgroundColor: 'rgba(0,0,0,1)',
              showBackground: false,
              outlineColor: 'rgba(255, 255, 255, 1)',
              outlineWidth: 5,
              style: Cesium.LabelStyle.FILL_AND_OUTLINE,
              distanceDisplayCondition: [Number.MIN_VALUE, 7000000],
            },
          },
        }))
    );
    if (newfiberMap.getLayers(newfiberId).length > 0) {
      return;
    } else {
      newfiberMap.geojsonToMap(geojson);
    }
  }
  //添加geojson立体墙
  static addGeojsonWall(newfiberMap, geojson, newfiberId) {
    geojson.features.forEach(feature => {
      feature.properties = Object.assign(feature.properties, {
        style_: {
          type: NewFiberMap.Enum.VectorType.WALL,
          id: newfiberId,
          options: {
            maximumHeights: 500,
            minimunHeights: 0,
            material: new NewFiberMap.Material.WallTrailMaterialProperty({
              color: new Cesium.Color.fromCssColorString(feature.properties.fillcolor) || Cesium.Color.RED,
              speed: 1000,
            }),
          },
        },
      });
    });
    newfiberMap.geojsonToMap(geojson);
  }
  //添加动态河流
  static addDynamicWater(newfiberMap, geojson, newfiberId) {
    NewFiberMap.Layer.Primitive.loadWaterPrimitive({ geojson: geojson, height: 10, id: newfiberId, show: true }, newfiberMap.getMap());
  }
  //动态河流显示与隐藏
  static setDynamicWaterVisible(visible) {
    let dynamicWaterList = newfiberMap.getMap().scene.primitives._primitives.filter(i => i.key == 'dynamicWater');
    dynamicWaterList.map(feature => {
      feature.show = visible;
    });
  }
  //添加三维模型
  static add3DModelLayers(newfiberMap, url, newfiberId) {
    let modelList = newfiberMap.getMap().scene.primitives._primitives.filter(i => i.newfiberId == newfiberId);
    if (!modelList.length) {
      let models = new SuperMap3D.S3MTilesLayer({
        context: newfiberMap.getMap().scene.context,
        url: url,
      });
      models.newfiberId = newfiberId;
      newfiberMap.getMap().scene.primitives.add(models);
    } else {
      newfiberVectorLayer.set3DModelVisible(newfiberId, true);
    }
  }
  //隐藏三维模型
  static set3DModelVisible(newfiberId, visible) {
    let models = newfiberMap.getMap().scene.primitives._primitives.filter(i => i.newfiberId == newfiberId);
    models.map(feature => {
      feature.show = visible;
    });
  }
}