diff --git a/src/clusterfeaturelayer.js b/src/clusterfeaturelayer.js index c595dbe..b0f37cb 100755 --- a/src/clusterfeaturelayer.js +++ b/src/clusterfeaturelayer.js @@ -174,7 +174,9 @@ define([ // Optional. Font to use for TextSymbol. Default is 10pt, Arial. // spatialReference: SpatialReference? // Optional. Spatial reference for all graphics in the layer. This has to match the spatial reference of the map. Default is 102100. Omit this if the map uses basemaps in web mercator. - this._clusterTolerance = options.distance || 50; + // maxZoom: Number? + // Optional. Max zoom level to stop cluster the points. default value is this._map.getMaxZoom(). + this._clusterTolerance = this._initClusterTolerance = options.distance || 50; this._clusterData = []; this._clusters = []; this._clusterLabelColor = options.labelColor || '#000'; @@ -192,6 +194,7 @@ define([ this._singleTemplate = options.singleTemplate || new PopupTemplate({ 'title': '', 'description': '{*}' }); this._disablePopup = options.disablePopup || false; this._maxSingles = options.maxSingles || 10000; + this._maxZoom = options.hasOwnProperty('maxZoom') ? options.maxZoom : undefined; this._font = options.font || new Font('10pt').setFamily('Arial'); @@ -282,6 +285,9 @@ define([ if (!this.suspended) { // update resolution this._clusterResolution = this._map.extent.getWidth() / this._map.width; + + this._clusterTolerance = this._map.getZoom() >= this._maxZoom ? -1 : this._initClusterTolerance; + // Smarter cluster, only query when we have to // Fist time if (!this._visitedExtent) { @@ -371,6 +377,7 @@ define([ this._query.outSpatialReference = map.spatialReference; this._query.returnGeometry = true; this._query.outFields = this._outFields; + this._maxZoom = this._maxZoom != undefined && this._maxZoom < map.getMaxZoom() ? this._maxZoom : map.getMaxZoom(); // listen to extent-change so data is re-clustered when zoom level changes this._extentChange = on.pausable(map, 'extent-change', lang.hitch(this, '_reCluster')); // listen for popup hide/show - hide clusters when pins are shown