mirror of https://gitee.com/antv-l7/antv-l7
Merge branch 'feat_source_hooks' of https://github.com/antvis/L7 into feat_source_hooks
This commit is contained in:
commit
d42cb18bb9
|
@ -12,7 +12,6 @@ import React, { useEffect } from 'react';
|
|||
|
||||
export default () => {
|
||||
useEffect(() => {
|
||||
const SOC = 'CHN';
|
||||
const colors = {};
|
||||
const GDPSpeed = {
|
||||
'520000': 10, //贵州
|
||||
|
|
|
@ -112,10 +112,10 @@ export default () => {
|
|||
|
||||
scene.addLayer(layer);
|
||||
|
||||
layer.on('click', (e) => {
|
||||
console.log('layer click');
|
||||
console.log(e);
|
||||
});
|
||||
// layer.on('click', (e) => {
|
||||
// console.log('layer click');
|
||||
// console.log(e);
|
||||
// });
|
||||
|
||||
// setTimeout(() => {
|
||||
// layer.style({
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"author": "xiaoiver",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@antv/async-hook": "^2.2.4",
|
||||
"@antv/async-hook": "^2.2.5",
|
||||
"@antv/l7-utils": "2.9.36",
|
||||
"@babel/runtime": "^7.7.7",
|
||||
"@turf/helpers": "^6.1.4",
|
||||
|
|
|
@ -141,7 +141,7 @@ export default class LayerService implements ILayerService {
|
|||
this.alreadyInRendering = true;
|
||||
this.clear();
|
||||
for (const layer of this.layerList) {
|
||||
layer.hooks.beforeRenderData.promise();
|
||||
await layer.hooks.beforeRenderData.promise();
|
||||
layer.hooks.beforeRender.call();
|
||||
|
||||
if (layer.masks.length > 0) {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"author": "xiaoiver",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@antv/async-hook": "^2.2.4",
|
||||
"@antv/async-hook": "^2.2.5",
|
||||
"@antv/l7-core": "2.9.36",
|
||||
"@antv/l7-maps": "2.9.36",
|
||||
"@antv/l7-source": "2.9.36",
|
||||
|
|
|
@ -36,12 +36,18 @@ export default class DataMappingPlugin implements ILayerPlugin {
|
|||
this.generateMaping(layer, { styleAttributeService });
|
||||
});
|
||||
|
||||
layer.hooks.beforeRenderData.tapPromise('DataMappingPlugin', async () => {
|
||||
layer.dataState.dataMappingNeedUpdate = false;
|
||||
this.generateMaping(layer, { styleAttributeService });
|
||||
layer.hooks.beforeRenderData.tapPromise(
|
||||
'DataMappingPlugin',
|
||||
async (flag: boolean) => {
|
||||
if (!flag) {
|
||||
return flag;
|
||||
}
|
||||
layer.dataState.dataMappingNeedUpdate = false;
|
||||
this.generateMaping(layer, { styleAttributeService });
|
||||
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
},
|
||||
);
|
||||
|
||||
// remapping before render
|
||||
layer.hooks.beforeRender.tap('DataMappingPlugin', () => {
|
||||
|
|
|
@ -71,19 +71,25 @@ export default class FeatureScalePlugin implements ILayerPlugin {
|
|||
});
|
||||
|
||||
// 检测数据是否需要更新
|
||||
layer.hooks.beforeRenderData.tapPromise('FeatureScalePlugin', async () => {
|
||||
this.scaleOptions = layer.getScaleOptions();
|
||||
const attributes = styleAttributeService.getLayerStyleAttributes();
|
||||
const dataArray = layer.getSource().data.dataArray;
|
||||
layer.hooks.beforeRenderData.tapPromise(
|
||||
'FeatureScalePlugin',
|
||||
async (flag: boolean) => {
|
||||
if (!flag) {
|
||||
return flag;
|
||||
}
|
||||
this.scaleOptions = layer.getScaleOptions();
|
||||
const attributes = styleAttributeService.getLayerStyleAttributes();
|
||||
const dataArray = layer.getSource().data.dataArray;
|
||||
|
||||
if (Array.isArray(dataArray) && dataArray.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.caculateScalesForAttributes(attributes || [], dataArray);
|
||||
layer.layerModelNeedUpdate = true;
|
||||
if (Array.isArray(dataArray) && dataArray.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.caculateScalesForAttributes(attributes || [], dataArray);
|
||||
layer.layerModelNeedUpdate = true;
|
||||
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
},
|
||||
);
|
||||
|
||||
layer.hooks.beforeRender.tap('FeatureScalePlugin', () => {
|
||||
const { usage } = layer.getLayerConfig();
|
||||
|
|
|
@ -28,9 +28,15 @@ export default class LayerModelPlugin implements ILayerPlugin {
|
|||
await this.initLayerModel(layer);
|
||||
});
|
||||
|
||||
layer.hooks.beforeRenderData.tapPromise('DataSourcePlugin', async () => {
|
||||
await this.prepareLayerModel(layer);
|
||||
return false;
|
||||
});
|
||||
layer.hooks.beforeRenderData.tapPromise(
|
||||
'DataSourcePlugin',
|
||||
async (flag: boolean) => {
|
||||
if (!flag) {
|
||||
return flag;
|
||||
}
|
||||
await this.prepareLayerModel(layer);
|
||||
return false;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,8 +83,7 @@ export class TileLayerService {
|
|||
this._tiles.map((tile: Tile) => {
|
||||
const layers = tile.getLayers();
|
||||
layers.forEach(async (layer: ILayer) => {
|
||||
layer.hooks.beforeRenderData.promise();
|
||||
|
||||
await layer.hooks.beforeRenderData.promise();
|
||||
layer.hooks.beforeRender.call();
|
||||
|
||||
if (layer.masks.length > 0) {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"author": "lzxue",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@antv/async-hook": "^2.2.4",
|
||||
"@antv/async-hook": "^2.2.5",
|
||||
"@antv/l7-core": "2.9.36",
|
||||
"@antv/l7-utils": "2.9.36",
|
||||
"@babel/runtime": "^7.7.7",
|
||||
|
|
Loading…
Reference in New Issue