首页 / 浏览问题 / 三维GIS / 问题详情
Cesium3DTileStyle 样式设置
19EXP 2023年08月02日
Cesium3DTileStyle根据属性值设置样式时应该如何匹配,如:name属性为农村的设置为红色,name属性为城镇的设置为黄色。conditions内的匹配字符串应该怎么写

1个回答

这是一段demo,请按照您的实际情况去写代码。

var colors = [
            'rgba(0, 0, 154,1)', // rgb(24, 255, 93)
            'rgba(80, 170, 255,1)', // rgb(24, 255, 93)
            'rgba(165, 243, 255,1)', // rgb(10, 25, 68)
            'rgba(255, 249, 0,1)', // rgb(10, 25, 250)
            'rgba(255, 48, 0,1)', // rgb(255, 133, 102)
            'rgba(170, 0, 0,1)', // rgb(255, 233, 15)
            'rgba(141, 0, 0,1)' // rgb(255, 15, 15)
          ]
          const rule = {
            fieldName: "name",
            type: 'subsection',
            rule: [
              {
                minValue: -100,
                maxValue: -40,
                color: '#ff0000',
                show: true
              },
              {
                minValue: -40,
                maxValue: -20,
                color: '#000000',
                show: true
              },
              {
                minValue: -20,
                maxValue: 0,
                color: '#FF457F',
                show: true
              },
              {
                minValue: 0,
                maxValue: 20,
                color: '#FF45AA',
              },
              {
                minValue: 20,
                maxValue: 40,
                color: '#FF45D4',
                show: true
              },
            ],
          }
          setStyleMapBoxlayer('testMVT', rule)
          function setStyleMapBoxlayer (name, rule) {
            const mvtlayer = viewer.scene.getVectorTilesLayer(name)
            resetStlye(name)
            switchStyle(rule, mvtlayer)
          }
          function switchStyle (rule, mvtlayer) {
            const filedname = rule.fieldName
            let newStyleLayer
            switch (rule.type) {
              case 'subsection':
                subsectrans(rule.rule, filedname, mvtlayer.mapboxStyle.layers[0], mvtlayer)
                break
              case 'singlevalue':
                matchtrans(rule.rule, filedname, mvtlayer.mapboxStyle.layers[0], mvtlayer)
                break
            }
4,151EXP 2023年08月02日
...