fix: 修复 shape 更新失效 (#1547)

Co-authored-by: shihui <yiqianyao.yqy@alibaba-inc.com>
This commit is contained in:
YiQianYao 2022-12-19 17:54:53 +08:00 committed by GitHub
parent 55ae0001c9
commit debd0bff41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 22 deletions

View File

@ -51,26 +51,31 @@ export default () => {
.active(false)
.size(20);
scene.addLayer(imageLayer);
imageLayer.on('mousedown', (e) => {
console.log('mousedown', e);
});
const popup = new Popup({
});
scene.addPopup(popup);
imageLayer.on('click', (e) => {
console.log(e)
const {lng,lat} = e.lngLat
popup.setOptions({
title: e.feature.name,
html:e.feature.name,
lngLat: {
lng,
lat,
},
});
});
setTimeout(() => {
imageLayer.shape('02');
scene.render();
}, 4000)
// imageLayer.on('mousedown', (e) => {
// console.log('mousedown', e);
// });
// const popup = new Popup({
// });
// scene.addPopup(popup);
// imageLayer.on('click', (e) => {
// console.log(e)
// const {lng,lat} = e.lngLat
// popup.setOptions({
// title: e.feature.name,
// html:e.feature.name,
// lngLat: {
// lng,
// lat,
// },
// });
// });
}, []);
return (

View File

@ -13,11 +13,11 @@ const shapeUpdateList = [
['rhombus', 'cylinder'],
['vesica', 'cylinder'],
];
export function updateShape(
export async function updateShape(
layer: ILayer,
lastShape: StyleAttributeField | undefined,
currentShape: StyleAttributeField | undefined,
): void {
) {
if (
typeof lastShape === 'string' &&
typeof currentShape === 'string' &&
@ -25,13 +25,17 @@ export function updateShape(
) {
if (layer.type === 'PointLayer') {
layer.dataState.dataSourceNeedUpdate = true;
await layer.hooks.beforeRenderData.promise();
layer.renderLayers();
return;
}
shapeUpdateList.map((shapes) => {
shapeUpdateList.map(async (shapes) => {
if (shapes.includes(lastShape) && shapes.includes(currentShape)) {
// dataSourceNeedUpdate 借用数据更新时更新 layer model 的工作流
layer.dataState.dataSourceNeedUpdate = true;
await layer.hooks.beforeRenderData.promise();
layer.renderLayers();
return;
}
});