antvis / L7

🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis engine.

Home Page:https://l7.antv.antgroup.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

在事件中根据字段动态设置opacity时无效或报错

tsuyoii opened this issue · comments

问题描述

在事件中根据字段动态设置opacity时无效或报错
代码:
gw_layer.on('click', (e: any) => {
scene?.getLayerByName('分组')?.style({
opacity: {
field: 'type',
value: (type: any) => {
return type === 'a' ? 0.1 : 1;
}
}
});
})

效果:无效

另一种写法:
代码:
gw_layer.on('click', (e: any) => {
scene?.getLayerByName('分组')?.style({
opacity: {
field: 'type',
value: [0, 0.3, 1]
}
});
})
效果:第一次点击无反应,第二次点击后报错
WeChat8d863f4fe6b7adbb6fbcbb993d6f7abe

重现链接

No response

重现步骤

No response

预期行为

No response

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]

屏幕截图或视频(可选)

WeChat8d863f4fe6b7adbb6fbcbb993d6f7abe

补充说明(可选)

No response

Hi @tsuyoii, Please star this repo if you find it useful! Thanks ⭐!
你好~ @tsuyoii 🌟 如果这个仓库对你有帮助,可以给我们点个star支持一下~你的支持对我们来说是最大的鼓励,感谢你的支持与点赞 🌟

codesanbox 复现一下~

https://l7.antv.antgroup.com/zh/examples/polygon/3d/#polygon_stylemap 可以参照这个demo

在scene.on('loaded', () => {})中可以生效,但是当我放到事件中(例如这里的click事件里)就不生效了

初始化的会判断是 Opacity 是数据映射还是常量,开始没有设置 opacity ,初始化haul的任务是常量。

初始化时可以这样写

.style({
          opacity: {
            field: 'unit_price',
            value: 1,
          },
        })

初始化的会判断是 Opacity 是数据映射还是常量,开始没有设置 opacity ,初始化haul的任务是常量。

初始化时可以这样写

.style({
          opacity: {
            field: 'unit_price',
            value: 1,
          },
        })

成功啦,感谢大佬