From 017211395afc3784b00c16338976e6cc766ff05a Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 15 Feb 2018 13:50:32 +0100 Subject: [PATCH] Add new maxTilesLoading option to ol/PluggableMap To be able to set the maximum number of currently loading tiles. --- externs/olx.js | 7 +++++++ src/ol/PluggableMap.js | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/externs/olx.js b/externs/olx.js index ae436811b5..cd39808c64 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -3649,6 +3649,7 @@ olx.layer.TileOptions.prototype.zIndex; * map: (ol.PluggableMap|undefined), * declutter: (boolean|undefined), * style: (ol.style.Style|Array.|ol.StyleFunction|undefined), + * maxTilesLoading: (number|undefined), * updateWhileAnimating: (boolean|undefined), * updateWhileInteracting: (boolean|undefined), * visible: (boolean|undefined), @@ -3763,6 +3764,12 @@ olx.layer.VectorOptions.prototype.declutter; olx.layer.VectorOptions.prototype.style; +/** + * Maximum number tiles to load simultaneously. Default is `16`. + * @type {number|undefined} + */ +olx.layer.VectorOptions.prototype.maxTilesLoading; + /** * When set to `true`, feature batches will be recreated during animations. * This means that no vectors will be shown clipped, but the setting will have a diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index ec018bf7e2..689c8d0dd5 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -76,6 +76,8 @@ export let MapOptions; * Note that layers are rendered in the order supplied, so if you want, for * example, a vector layer to appear on top of a tile layer, it must come * after the tile layer. + * @param {number|undefined} options.maxTilesLoading Maximum number tiles to load + * simultaneously. Default is `16`. * @param {boolean|undefined} options.loadTilesWhileAnimating When set to true, * tiles will be loaded during animations. This may improve the user * experience, but can also make animations stutter on devices with slow @@ -115,6 +117,12 @@ const PluggableMap = function(options) { const optionsInternal = createOptionsInternal(options); + /** + * @type {number} + * @private + */ + this.maxTilesLoading_ = options.maxTilesLoading !== undefined ? options.maxTilesLoading : 16; + /** * @type {boolean} * @private @@ -945,7 +953,7 @@ PluggableMap.prototype.handlePostRender = function() { // loading tiles that will quickly disappear from view. const tileQueue = this.tileQueue_; if (!tileQueue.isEmpty()) { - let maxTotalLoading = 16; + let maxTotalLoading = this.maxTilesLoading_; let maxNewLoads = maxTotalLoading; if (frameState) { const hints = frameState.viewHints;