From 09dd98df17bd764015a4f5bc9ae0024b8ee6c367 Mon Sep 17 00:00:00 2001 From: ryanhamley Date: Tue, 29 Oct 2019 16:46:13 -0700 Subject: [PATCH] Go back to previous algorithm --- src/render/painter.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/render/painter.js b/src/render/painter.js index c9991992cc5..166bc4cda85 100644 --- a/src/render/painter.js +++ b/src/render/painter.js @@ -432,16 +432,24 @@ class Painter { if (this.options.showTileBoundaries) { //Use source with highest maxzoom - let maxZoomSourceCache; - for (const source in this.style.sourceCaches) { - const cache = this.style.sourceCaches[source]; - if (!maxZoomSourceCache || cache._source.maxzoom > maxZoomSourceCache._source.maxZoom) { - maxZoomSourceCache = cache; + let selectedSource; + let sourceCache; + const layers = values(this.style._layers); + + layers.forEach((layer) => { + if (layer.source && !layer.isHidden(this.transform.zoom)) { + if (layer.source !== (sourceCache && sourceCache.id)) { + sourceCache = this.style.sourceCaches[layer.source]; + } + + if (!selectedSource || (selectedSource.getSource().maxzoom < sourceCache.getSource().maxzoom)) { + selectedSource = sourceCache; + } } - } + }); - if (maxZoomSourceCache) { - draw.debug(this, maxZoomSourceCache, maxZoomSourceCache.getVisibleCoordinates()); + if (selectedSource) { + draw.debug(this, selectedSource, selectedSource.getVisibleCoordinates()); } }