-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
颜色规则更新,layer.color()不执行 #2070
Comments
hi @fishhotter, welcome! |
Hi @fishhotter, Please star this repo if you find it useful! Thanks ⭐! |
需要调用scene.render 方法 |
有调用scene.render() 还是没有用额
|
|
代码能不能加上代码标签,没法读 console.log('setColor-------------------', color); |
|
问题描述
"name": "@antv/l7",
"version": "2.19.11",
"name": "@antv/l7-maps",
"version": "2.19.11",
监听颜色和高度规则,动态更新颜色和高度
更新失效
重现链接
No response
重现步骤
let layer;
let scene;
const initLayer = () => {
// 创建3D柱状图图层
scene = new Scene({
id: map.getCanvasContainer(),
map: new Mapbox({
mapInstance: map
}),
logoVisible: false
});
scene.on('loaded', () => {
layer = new PointLayer({ zIndex: 10 })
.source([], {
parser: {
type: 'json',
y: 'y',
x: 'x'
}
})
.animate(true)
.active(true)
.shape('hexagonColumn')
.size('count', (h) => {
return [6, 6, h];
})
.color('color');
scene.addLayer(layer);
// layer?.hide();
// layer && layer.setData(pointsData.value);
});
};
initLayer();
const setColor = (d) => {
console.log('d-----------------------------------------------', d);
let color;
for (let index = 0; index < styleLegend.value.length; index++) {
const element = styleLegend.value[index];
const min = Number(element.min);
const max = Number(element.max);
if (min <= d && d < max) {
const rgbArr = element.color.replace('rgb(', '').replace(')', '').split(',');
rgbArr.push(element.opacity);
color =
rgba(${rgbArr.join()})
;}
}
console.log('setColor-------------------', color);
return color || '#FFDE74';
};
watch(
() => styleLegend.value,
(newVal) => {
console.log('--------------------------', newVal);
layer.color('count', setColor); //就第一次会进到callback 后面styleLegend改变,setColor没有执行
scene.render();
}
);
预期行为
希望layer.color('count', setColor);能够正常执行
目前setColor回调没有执行 颜色更新不成功
size也是一样的
平台
Windows64
Google Chrome
屏幕截图或视频(可选)
No response
补充说明(可选)
No response
The text was updated successfully, but these errors were encountered: