Skip to content

Commit

Permalink
Fix terrain "source" error being fired when using map.getStyle() wi…
Browse files Browse the repository at this point in the history
…th globe view (#12163)

* fix terrain error being fired with globe projection, added unit tests
  • Loading branch information
avpeery authored Aug 22, 2022
1 parent b5ac1da commit d45dcaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -1222,12 +1222,13 @@ class Style extends Evented {
sources[source.id] = source.serialize();
}
}

return filterObject({
version: this.stylesheet.version,
name: this.stylesheet.name,
metadata: this.stylesheet.metadata,
light: this.stylesheet.light,
terrain: this.stylesheet.terrain,
terrain: this.getTerrain() || undefined,
fog: this.stylesheet.fog,
center: this.stylesheet.center,
zoom: this.stylesheet.zoom,
Expand Down
4 changes: 4 additions & 0 deletions test/unit/ui/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ test('Map', (t) => {
t.equal(initStyleObj.setTerrain.callCount, 1);
t.ok(map.style.terrain);
t.equal(map.getTerrain(), null);
t.equal(map.getStyle().terrain, undefined);
t.end();
});
});
Expand All @@ -356,6 +357,7 @@ test('Map', (t) => {
t.equal(initStyleObj.setTerrain.callCount, 1);
t.ok(map.style.terrain);
t.equal(map.getTerrain(), null);
t.equal(map.getStyle().terrain, undefined);
map.setZoom(12); // Above threshold for Mercator transition
map.once('render', () => {
t.notOk(map.style.terrain);
Expand All @@ -375,11 +377,13 @@ test('Map', (t) => {
t.equal(initStyleObj.setTerrain.callCount, 0);
t.notOk(map.style.terrain);
t.equal(map.getTerrain(), null);
t.equal(map.getStyle().terrain, undefined);
map.setZoom(3); // Below threshold for Mercator transition
map.once('render', () => {
t.equal(initStyleObj.setTerrain.callCount, 1);
t.ok(map.style.terrain);
t.equal(map.getTerrain(), null);
t.equal(map.getStyle().terrain, undefined);
t.end();
});
});
Expand Down

0 comments on commit d45dcaf

Please sign in to comment.