fix(boundary): county

fix: #492
This commit is contained in:
thinkinggis 2020-09-01 11:06:58 +08:00
parent a371768cee
commit 9ae4fb5469
4 changed files with 722 additions and 340 deletions

View File

@ -7,7 +7,7 @@
},
"devDependencies": {
"@antv/g2": "^3.5.9",
"@antv/gatsby-theme-antv": "^0.11.5",
"@antv/gatsby-theme-antv": "0.10.59",
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-decorators": "^7.6.0",

View File

@ -36,6 +36,7 @@ export default class BaseLayer extends EventEmitter {
protected options: IDistrictLayerOption;
protected layers: ILayer[] = [];
protected fillData: any;
protected bubbleData: any;
private popup: IPopup;
constructor(scene: Scene, option: Partial<IDistrictLayerOption> = {}) {
@ -87,6 +88,23 @@ export default class BaseLayer extends EventEmitter {
},
],
});
// 气泡图也需要更新
if(this.bubbleLayer) {
this.bubbleLayer.setData(this.bubbleData, {
transforms:
data.length === 0
? []
: [
{
type: 'join',
sourceField: joinBy[1], // data1 对应字段名
targetField: joinBy[0], // data 对应字段名 绑定到的地理数据
data,
},
],
});
}
}
protected async fetchData(data: { url: any; type: string }) {
if (data.type === 'pbf') {
@ -215,6 +233,8 @@ export default class BaseLayer extends EventEmitter {
center: [feature.properties.x, feature.properties.y],
};
});
this.bubbleData = labeldata;
this.addBubbleLayer(labeldata);
}
if (popup.enable) {

View File

@ -195,6 +195,24 @@ export default class Country extends React.Component {
value: null,
},
];
const ProvinceData2 = [
{
name: '云南省',
code: 530000,
value: 178810.12,
},
{
name: '黑龙江省',
code: 230000,
value: 163610.62,
},
{
name: '贵州省',
code: 520000,
value: 148060.45,
}
]
scene.on('loaded', () => {
const Layer = new CountryLayer(scene, {
data: ProvinceData,
@ -204,7 +222,7 @@ export default class Country extends React.Component {
enable: true,
size: {
field: 'value',
values: [3, 20],
values: [8, 20],
},
},
popup: {
@ -214,6 +232,10 @@ export default class Country extends React.Component {
},
},
});
setTimeout(() => {
Layer.updateData(ProvinceData2);
}, 2000);
});
this.scene = scene;
}

1016
yarn.lock

File diff suppressed because it is too large Load Diff