Merge pull request #443 from antvis/fix_update

fix(layer): 图层更新问题
This commit is contained in:
@thinkinggis 2020-07-20 11:07:32 +08:00 committed by GitHub
commit e6c9e461e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 34 deletions

View File

@ -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 顶点生成其他顶点数据

View File

@ -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();
});
});