Skip to content

Commit

Permalink
wip: 复现设置数据为空的案例
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed May 17, 2024
1 parent 5e4a474 commit 6f9e431
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/demos/bugfix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { MapRender as event_legend } from './event_legend';
export { MapRender as mutiPolygon } from './muti-polygon';
export { MapRender as remove_muti_layer } from './remove-muti-layer';
export { MapRender as setData } from './set-data';
export { MapRender as setDataEmpty } from './set-data-empty';
export { MapRender as size } from './size';
export { MapRender as text } from './text_offsets';
export { MapRender as tile_update } from './tile_update';
Expand Down
81 changes: 81 additions & 0 deletions examples/demos/bugfix/set-data-empty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { PointLayer, Scene } from '@antv/l7';
import * as allMap from '@antv/l7-maps';
import type { RenderDemoOptions } from '../../types';

export function MapRender(options: RenderDemoOptions) {
const scene = new Scene({
id: 'map',
renderer: options.renderer,
map: new allMap[options.map]({
style: 'light',
center: [120.100535, 30.041909],
zoom: 14.83,
}),
});

fetch(
'https://mdn.alipayobjects.com/afts/file/A*bcirT44OXmcAAAAAAAAAAAAADrd2AQ/new-housing-data-in-jzh.json',
)
.then((res) => res.json())
.then((data) => {
const layer = new PointLayer({
autoFit: false,
})
.source(data, {
parser: {
type: 'json',
x: '经度',
y: '纬度',
},
})
.scale('均价(元/平米)', { type: 'quantile' })
.shape('circle')
.active(false)
.size('参考总价(万元)', [8, 16])
.color('均价(元/平米)', ['#ffffcc', '#d9f0a3', '#addd8e', '#78c679', '#31a354', '#006837'])
.style({
opacity: 0.8,
});

const highlightStrokeLayer = new PointLayer({
autoFit: false,
})
.source([], {
parser: {
type: 'json',
x: '经度',
y: '纬度',
},
})
.shape('circle')
.size(16)
.color('red')
.style({
opacity: 0,
stroke: 'yellow',
strokeOpacity: 1,
strokeWidth: 2,
});

layer.once('inited', () => {
layer.fitBounds({ animate: false });
});

scene.addLayer(layer);
scene.addLayer(highlightStrokeLayer);

layer.on('mousemove', (event: any) => {
const { feature, featureId } = event;
const data = [feature];

const encodedData = layer.getEncodedData();
const encodedFeature = encodedData.find((item) => item.id === featureId);
const featureSize = encodedFeature?.size as number;
highlightStrokeLayer.setData(data);
highlightStrokeLayer.size(featureSize);
});
layer.on('mouseout', (event: any) => {

Check warning on line 77 in examples/demos/bugfix/set-data-empty.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'event' is defined but never used
highlightStrokeLayer.setData([]);
});
});
}
6 changes: 4 additions & 2 deletions packages/renderer/src/device/DeviceModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ export default class DeviceModel implements IModel {
this.indexBuffer = (elements as DeviceElements).get();
}

const inputLayout = service.renderCache.createInputLayout({
// const inputLayout = service.renderCache.createInputLayout({
const inputLayout = device.createInputLayout({
vertexBufferDescriptors,
indexBufferFormat: elements ? Format.U32_R : null,
program: this.program,
});
this.inputLayout = inputLayout;
console.log('inputLayout: ', inputLayout);

this.pipeline = this.createPipeline(options);
}
Expand Down Expand Up @@ -364,7 +366,7 @@ export default class DeviceModel implements IModel {
this.indexBuffer?.destroy();
this.bindings?.destroy();
// 不能进行销毁,删除 deleteVertexArray
// this.inputLayout.destroy();
this.inputLayout.destroy();
this.pipeline.destroy();
this.destroyed = true;
}
Expand Down

0 comments on commit 6f9e431

Please sign in to comment.