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; verticesForCurrentFeature.length / vertexSize;
// 记录三角化结果,用于后续精确更新指定 feature // 记录三角化结果,用于后续精确更新指定 feature
// this.featureLayout.sizePerElement = size; this.featureLayout.sizePerElement = size;
// this.featureLayout.elements.push({ this.featureLayout.elements.push({
// featureIdx, featureIdx,
// vertices: verticesForCurrentFeature, vertices: verticesForCurrentFeature,
// normals: normalsForCurrentFeature as number[], normals: normalsForCurrentFeature as number[],
// offset: verticesNum, offset: verticesNum,
// }); });
verticesNum += verticesNumForCurrentFeature; verticesNum += verticesNumForCurrentFeature;
// 根据 position 顶点生成其他顶点数据 // 根据 position 顶点生成其他顶点数据

View File

@ -123,41 +123,27 @@ export default class TextLayerDemo extends React.Component {
}); });
scene.on('loaded', () => { scene.on('loaded', () => {
const layer = new PolygonLayer({}) const layer = new PolygonLayer({})
.source({ .source(data)
type: 'FeatureCollection', .shape('fill')
features: [],
})
.shape('extrude')
.scale('childrenNum', { .scale('childrenNum', {
type: 'quantile', type: 'quantile',
}) })
.size('childrenNum', [10, 100000000]) .color('childrenNum', [
// .color('red') '#D92568',
// .color('childrenNum', [ '#E3507E',
// '#D92568', '#FC7AAB',
// '#E3507E', '#F1D3E5',
// '#FC7AAB', '#A7B5E3',
// '#F1D3E5', '#F2EEFF',
// '#A7B5E3', ])
// '#F2EEFF',
// ])
.color('childrenNum*name', (childrenNum, name) => {
console.log(childrenNum, name);
return 'red';
})
.style({ .style({
opacity: 1.0, opacity: 1.0,
}); });
scene.addLayer(layer); scene.addLayer(layer);
setTimeout(() => {
layer.setData(data);
console.log('update');
}, 2000);
layer.on('click', (e) => {
console.log(e);
});
this.scene = scene; this.scene = scene;
layer.on('remapping', ()=>{
console.log('remapinbg event')
});
const gui = new dat.GUI(); const gui = new dat.GUI();
this.gui = gui; this.gui = gui;
const styleOptions = { const styleOptions = {
@ -206,6 +192,7 @@ export default class TextLayerDemo extends React.Component {
]) ])
.onChange((color: any) => { .onChange((color: any) => {
layer.color('childrenNum', RMBColor[color] as string[]); layer.color('childrenNum', RMBColor[color] as string[]);
// layer.shape('fill');
scene.render(); scene.render();
}); });
}); });