mirror of https://gitee.com/antv-l7/antv-l7
Merge pull request #672 from yu-tou/master
fix: cluster 模式下,point 后续 setData,不会立即生效
This commit is contained in:
commit
e14838449e
|
@ -13,12 +13,12 @@ export default class DataSourcePlugin implements ILayerPlugin {
|
|||
this.updateClusterData(layer);
|
||||
});
|
||||
|
||||
// 检测数据不否需要更新
|
||||
// 检测数据是否需要更新
|
||||
layer.hooks.beforeRenderData.tap('DataSourcePlugin', () => {
|
||||
const neeUpdate1 = this.updateClusterData(layer);
|
||||
const neeUpdate2 = layer.dataState.dataSourceNeedUpdate;
|
||||
const neeUpdateCluster = this.updateClusterData(layer);
|
||||
const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
|
||||
layer.dataState.dataSourceNeedUpdate = false;
|
||||
return neeUpdate1 || neeUpdate2;
|
||||
return neeUpdateCluster || dataSourceNeedUpdate;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,13 @@ export default class DataSourcePlugin implements ILayerPlugin {
|
|||
const cluster = source.cluster;
|
||||
const { zoom = 0, maxZoom = 16 } = source.clusterOptions;
|
||||
const newZoom = this.mapService.getZoom() - 1;
|
||||
if (cluster && Math.abs(zoom - newZoom) > 1 && maxZoom > zoom) {
|
||||
const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
|
||||
// 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次
|
||||
if (
|
||||
cluster &&
|
||||
(dataSourceNeedUpdate || Math.abs(zoom - newZoom) > 1) &&
|
||||
maxZoom > zoom
|
||||
) {
|
||||
source.updateClusterData(Math.floor(newZoom));
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue