diff --git a/dev-demos/features/point/demos/icons.tsx b/dev-demos/features/point/demos/icons.tsx index 898fd35e43..09860a1eb3 100644 --- a/dev-demos/features/point/demos/icons.tsx +++ b/dev-demos/features/point/demos/icons.tsx @@ -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 ( diff --git a/packages/layers/src/utils/updateShape.ts b/packages/layers/src/utils/updateShape.ts index 249f76ea08..d907bd55b1 100644 --- a/packages/layers/src/utils/updateShape.ts +++ b/packages/layers/src/utils/updateShape.ts @@ -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; } });