From 741c0a9154ddc25c90e5e6ba7008f81647435975 Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Mon, 20 Jul 2020 10:44:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(layer):=20=E5=9B=BE=E5=B1=82=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/layer/StyleAttributeService.ts | 14 +++---- stories/Layers/components/polygon.tsx | 41 +++++++------------ 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/packages/core/src/services/layer/StyleAttributeService.ts b/packages/core/src/services/layer/StyleAttributeService.ts index 8408171a94..ca404befab 100644 --- a/packages/core/src/services/layer/StyleAttributeService.ts +++ b/packages/core/src/services/layer/StyleAttributeService.ts @@ -225,13 +225,13 @@ export default class StyleAttributeService implements IStyleAttributeService { verticesForCurrentFeature.length / vertexSize; // 记录三角化结果,用于后续精确更新指定 feature - // this.featureLayout.sizePerElement = size; - // this.featureLayout.elements.push({ - // featureIdx, - // vertices: verticesForCurrentFeature, - // normals: normalsForCurrentFeature as number[], - // offset: verticesNum, - // }); + this.featureLayout.sizePerElement = size; + this.featureLayout.elements.push({ + featureIdx, + vertices: verticesForCurrentFeature, + normals: normalsForCurrentFeature as number[], + offset: verticesNum, + }); verticesNum += verticesNumForCurrentFeature; // 根据 position 顶点生成其他顶点数据 diff --git a/stories/Layers/components/polygon.tsx b/stories/Layers/components/polygon.tsx index 7562d48693..9b6301401a 100644 --- a/stories/Layers/components/polygon.tsx +++ b/stories/Layers/components/polygon.tsx @@ -123,41 +123,27 @@ export default class TextLayerDemo extends React.Component { }); scene.on('loaded', () => { const layer = new PolygonLayer({}) - .source({ - type: 'FeatureCollection', - features: [], - }) - .shape('extrude') + .source(data) + .shape('fill') .scale('childrenNum', { type: 'quantile', }) - .size('childrenNum', [10, 100000000]) - // .color('red') - // .color('childrenNum', [ - // '#D92568', - // '#E3507E', - // '#FC7AAB', - // '#F1D3E5', - // '#A7B5E3', - // '#F2EEFF', - // ]) - .color('childrenNum*name', (childrenNum, name) => { - console.log(childrenNum, name); - return 'red'; - }) + .color('childrenNum', [ + '#D92568', + '#E3507E', + '#FC7AAB', + '#F1D3E5', + '#A7B5E3', + '#F2EEFF', + ]) .style({ opacity: 1.0, }); scene.addLayer(layer); - setTimeout(() => { - layer.setData(data); - console.log('update'); - }, 2000); - layer.on('click', (e) => { - console.log(e); - }); this.scene = scene; - + layer.on('remapping', ()=>{ + console.log('remapinbg event') + }); const gui = new dat.GUI(); this.gui = gui; const styleOptions = { @@ -206,6 +192,7 @@ export default class TextLayerDemo extends React.Component { ]) .onChange((color: any) => { layer.color('childrenNum', RMBColor[color] as string[]); + // layer.shape('fill'); scene.render(); }); });