This commit is contained in:
@@ -155,6 +155,10 @@ export default {
|
||||
addTerrain() {
|
||||
// MapLibre terrain's fog matrix is only implemented for Mercator.
|
||||
this.map.setProjection({type: 'mercator'});
|
||||
//One shared raster-dem source feeds both the 3D elevation mesh
|
||||
//(setTerrain) and the hillshade layer below - they used to be two
|
||||
//separate sources pointed at the identical tile URL, which meant
|
||||
//every DEM tile was downloaded and decoded twice per viewport.
|
||||
if(!this.map.getSource('terrain-dem')) {
|
||||
this.map.addSource('terrain-dem', {
|
||||
type: 'raster-dem',
|
||||
@@ -164,20 +168,11 @@ export default {
|
||||
encoding: 'terrarium'
|
||||
});
|
||||
}
|
||||
if(!this.map.getSource('hillshade-dem')) {
|
||||
this.map.addSource('hillshade-dem', {
|
||||
type: 'raster-dem',
|
||||
tiles: ['https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png'],
|
||||
tileSize: 256,
|
||||
maxzoom: 13,
|
||||
encoding: 'terrarium'
|
||||
});
|
||||
}
|
||||
if(!this.map.getLayer('terrain-hillshade')) {
|
||||
this.map.addLayer({
|
||||
id: 'terrain-hillshade',
|
||||
type: 'hillshade',
|
||||
source: 'hillshade-dem',
|
||||
source: 'terrain-dem',
|
||||
paint: {
|
||||
'hillshade-exaggeration': 0.35,
|
||||
'hillshade-shadow-color': '#2d342b',
|
||||
@@ -191,7 +186,6 @@ export default {
|
||||
if(!this.map) return;
|
||||
if(this.map.getTerrain()) this.map.setTerrain(null);
|
||||
if(this.map.getLayer('terrain-hillshade')) this.map.removeLayer('terrain-hillshade');
|
||||
if(this.map.getSource('hillshade-dem')) this.map.removeSource('hillshade-dem');
|
||||
if(this.map.getSource('terrain-dem')) this.map.removeSource('terrain-dem');
|
||||
this.map.setProjection({type: 'globe'});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user