Skip to content

Commit

Permalink
Skip source reload for raster sources since style changes do not need…
Browse files Browse the repository at this point in the history
… to reload the source.
  • Loading branch information
Asheem Mamoowala committed Oct 22, 2019
1 parent 992a2b6 commit 5f03976
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,9 @@ class Style extends Evented {

_updateLayer(layer: StyleLayer) {
this._updatedLayers[layer.id] = true;
if (layer.source && !this._updatedSources[layer.source]) {
if (layer.source && !this._updatedSources[layer.source] &&
//Skip for raster layers (https://github.com/mapbox/mapbox-gl-js/issues/7865)
this.sourceCaches[layer.source].getSource().type !== 'raster') {
this._updatedSources[layer.source] = 'reload';
this.sourceCaches[layer.source].pause();
}
Expand Down
27 changes: 27 additions & 0 deletions test/unit/style/style.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,33 @@ test('Style#setLayerZoomRange', (t) => {
});
});

t.test('does not reload raster source', (t) => {
const style = new Style(new StubMap());
style.loadJSON({
"version": 8,
"sources": {
"raster": {
type: "raster",
tiles: ['http://tiles.server']
}
},
"layers": [{
"id": "raster",
"type": "raster",
"source": "raster"
}]
});

style.on('style.load', () => {
t.spy(style, '_reloadSource');

style.setLayerZoomRange('raster', 5, 12);
style.update(0);
t.notOk(style._reloadSource.called, '_reloadSource should not be called for raster source');
t.end();
});
});

t.end();
});

Expand Down

0 comments on commit 5f03976

Please sign in to comment.