fix(source): pointLayer相同经纬度点或extent在一条线上时不聚合

fix #633
This commit is contained in:
yanyu510 2021-03-29 16:28:05 +08:00
parent 2274154481
commit 4d401bb45a
1 changed files with 7 additions and 8 deletions

View File

@ -14,7 +14,6 @@ import {
import { import {
bBoxToBounds, bBoxToBounds,
extent, extent,
lnglatDistance,
padBounds, padBounds,
} from '@antv/l7-utils'; } from '@antv/l7-utils';
import { import {
@ -59,8 +58,8 @@ export default class Source extends EventEmitter {
zoom: -99, zoom: -99,
method: 'count', method: 'count',
}; };
// 数据范围框的对角线长度 // 是否有效范围
private extentDiagonalLength: number; private invalidExtent: boolean = false;
// 原始数据 // 原始数据
private originData: any; private originData: any;
@ -180,7 +179,9 @@ export default class Source extends EventEmitter {
[-Infinity, -Infinity], [-Infinity, -Infinity],
[Infinity, Infinity], [Infinity, Infinity],
]; ];
if (this.extentDiagonalLength > 0) {
if (!this.invalidExtent) {
newBounds = padBounds(bBoxToBounds(this.extent), bufferRatio); newBounds = padBounds(bBoxToBounds(this.extent), bufferRatio);
} }
return newBounds[0].concat(newBounds[1]); return newBounds[0].concat(newBounds[1]);
@ -213,10 +214,8 @@ export default class Source extends EventEmitter {
this.data = sourceParser(this.originData, parser); this.data = sourceParser(this.originData, parser);
// 计算范围 // 计算范围
this.extent = extent(this.data.dataArray); this.extent = extent(this.data.dataArray);
this.extentDiagonalLength = lnglatDistance( this.invalidExtent = this.extent[0]===this.extent[2] || this.extent[1]===this.extent[3]
[this.extent[0], this.extent[1]],
[this.extent[2], this.extent[3]],
);
} }
/** /**
* *