fix(boundary): 下钻能不能绑定数据的问题

fix #473 #442
This commit is contained in:
thinkinggis 2020-08-12 13:52:55 +08:00
parent d07db2b7b7
commit 69835f79d6
4 changed files with 26 additions and 6 deletions

View File

@ -66,7 +66,7 @@ export default class BaseLayer extends EventEmitter {
}
public updateData(
newData: Array<{ [key: string]: any }>,
newData?: Array<{ [key: string]: any }>,
joinByField?: [string, string],
) {
this.setOption({

View File

@ -62,6 +62,7 @@ export default class DrillDownLayer {
}
public addCountryEvent() {
const { drillDownTriggerEvent } = this.options;
// 省级下钻到市
this.provinceLayer.fillLayer.on(
drillDownTriggerEvent as string,
(e: any) => {
@ -102,7 +103,7 @@ export default class DrillDownLayer {
public showProvinceView(
adcode: adcodeType,
newData: Array<{ [key: string]: any }> = [],
newData?: Array<{ [key: string]: any }>,
joinByField?: [string, string],
) {
this.cityLayer.show();
@ -113,7 +114,7 @@ export default class DrillDownLayer {
}
public showCityView(
code: adcodeType,
newData: Array<{ [key: string]: any }> = [],
newData?: Array<{ [key: string]: any }>,
joinByField?: [string, string],
) {
this.countyLayer.show();
@ -149,7 +150,7 @@ export default class DrillDownLayer {
}
public drillDown(
adcode: adcodeType,
newData: Array<{ [key: string]: any }> = [],
newData?: Array<{ [key: string]: any }>,
joinByField?: [string, string],
) {
const { drillDepth } = this.options;

View File

@ -27,7 +27,7 @@ export default class ProvinceLayer extends BaseLayer {
// 通过adcode 更新
public updateDistrict(
adcode: adcodeType,
newData: Array<{ [key: string]: any }> = [],
newData?: Array<{ [key: string]: any }>,
joinByField?: [string, string],
) {
if (!adcode && Array.isArray(adcode) && adcode.length === 0) {

View File

@ -32,6 +32,25 @@ export default class Country extends React.Component {
this.drillDown = new DrillDownLayer(scene, {
drillDepth: 2,
geoDataLevel: 2,
joinBy: ['NAME_CHN', 'name'],
provinceData: [
{
name: '青海省',
value: '1223',
},
],
cityData: [
{
name: '海东市',
value: '1223e',
},
],
countyData: [
{
name: '平安区',
value: '456',
},
],
fill: {
color: {
field: 'NAME_CHN',
@ -51,7 +70,7 @@ export default class Country extends React.Component {
popup: {
enable: true,
Html: (props) => {
return `<span>${props.NAME_CHN}</span>`;
return `<span>${props.NAME_CHN} ${props.value}</span>`;
},
},
});