addflood () {
      let params = {}
      findtBuildField(params).then(res => {
        if (res.data.status === 0) {
          let conditions = []
          let tempArr = []
          tempArr = res.data.data
          for (let item of tempArr) { // 设置模型颜色渲染
                if (item.damagefield >= 0 && item.damagefield < 0.1) {
                  conditions.push(['${buildingId} === ' + item.buildingid, 'color("rgb(26, 150, 64)")'],)
                } else if (item.damagefield >= 0.1 && item.damagefield < 0.25) {
                  conditions.push(['${buildingId} === ' + item.buildingid, 'color("rgb(166, 217, 106)")'],)
                } else if (item.damagefield >= 0.25 && item.damagefield < 0.55) {
                  conditions.push(['${buildingId} === ' + item.buildingid, 'color("rgb(255, 255, 192)")'],)
                } else if (item.damagefield >= 0.55 && item.damagefield < 0.85) {
                  conditions.push(['${buildingId} === ' + item.buildingid, 'color("rgb(253, 174, 97)")'],)
                } else if (item.damagefield >= 0.85 && item.damagefield <= 1) {
                  conditions.push(['${buildingId} === ' + item.buildingid, 'color("rgb(215, 24, 28)")'],)
                } else {
                  conditions.push(['${buildingId} === ' + item.buildingid, 'color("rgb(26, 150, 64)")'],) // 当item.damagefield === undefined
                }
          }
    
          let tiles = new Cesium.Cesium3DTileset({
            url: './static/shp/tileset.json', // 带网络属性模板
          })
          let m = this._viewer.scene.primitives.add(tiles)
          m.style = new Cesium.Cesium3DTileStyle({
            color: {
              conditions: conditions
            }
          })
        } else {
          console.log(res.data.msg)
        }
      });
    }        

调用

this.addflood()

posted on 2020-09-16 18:01  番番bobo  阅读(707)  评论(0)    收藏  举报