Skip to content

Commit 32a8721

Browse files
committed
Optimize the logic of maxClusterZoom
1 parent 75d203a commit 32a8721

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ export class TileClusterLayer extends maptalks.VectorLayer {
194194
}
195195
const currentTileCache = this._currentTileCache, tileCache = this._tileCache, merc = this.merc, kdbush = this.kdbush;
196196
const cache = {};
197-
const zoom = Math.floor(this.getMap().getZoom());
197+
const mapZoom = this.getMap().getZoom();
198+
const zoom = Math.floor(mapZoom);
198199
const addMarkers = [], removeMarkers = [];
199200
for (let i = 0, len = tiles.length; i < len; i++) {
200201
const tile = tiles[i];
@@ -250,7 +251,7 @@ export class TileClusterLayer extends maptalks.VectorLayer {
250251
if (ids.length) {
251252
const { x, y, points, features } = this._getClusterResult(globalPoints, ids);
252253
tileCache[key].coordinates = [x, y];
253-
if (zoom > maxZoom || ids.length < this.options.minClusterCount) {
254+
if (zoom > (maxZoom - 1) || ids.length < this.options.minClusterCount) {
254255
tileCache[key].markers = ids.map(id => {
255256
const feature = globalFeatures[id];
256257
return new maptalks.Marker(globalPoints[id], {

0 commit comments

Comments
 (0)