Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 82 additions & 68 deletions debug/terrain.html
Original file line number Diff line number Diff line change
@@ -1,79 +1,93 @@
<!DOCTYPE html>
<html>

<head>
<title>MapLibre GL JS debug page for terrian</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel='stylesheet' href='../dist/maplibre-gl.css' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
<title>MapLibre GL JS debug page for terrian</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel='stylesheet' href='../dist/maplibre-gl.css' />
<style>
body {
margin: 0;
padding: 0;
}

html,
body,
#map {
height: 100%;
}
</style>
</head>

<body>
<div id='map'></div>

<script src='../dist/maplibre-gl-dev.js'></script>
<script>
<div id='map'></div>

var map = window.map = new maplibregl.Map({
container: 'map',
zoom: 12,
center: [11.39085, 47.27574],
pitch: 52,
hash: true,
style: {
version: 8,
sources: {
osm: {
type: 'raster',
tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],
tileSize: 256,
attribution: '&copy; OpenStreetMap Contributors',
maxzoom: 19
},
terrain: {
type: 'raster-dem',
url: 'https://api.maptiler.com/tiles/terrain-rgb/tiles.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL',
tileSize: 256
<script src='../dist/maplibre-gl-dev.js'></script>
<script>
var map = window.map = new maplibregl.Map({
container: 'map',
zoom: 12,
center: [11.39085, 47.27574],
pitch: 52,
hash: true,
style: {
version: 8,
sources: {
osm: {
type: 'raster',
tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],
tileSize: 256,
attribution: '&copy; OpenStreetMap Contributors',
maxzoom: 19
},
terrainSource: {
type: 'raster-dem',
url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json',
tileSize: 256
},
hillshadeSource: {
type: 'raster-dem',
url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json',
tileSize: 256
},
},
layers: [
{
id: 'osm',
type: 'raster',
source: 'osm'
},
{
id: 'hills',
type: 'hillshade',
source: 'hillshadeSource',
layout: {'visibility': 'visible'},
paint: {'hillshade-shadow-color': '#473B24'}
}
],
terrain: {
source: 'terrainSource',
exaggeration: 1
}
},
},
layers: [
{
id: 'osm',
type: 'raster',
source: 'osm'
},
{
id: 'hills',
type: 'hillshade',
source: 'terrain',
layout: {'visibility': 'visible'},
paint: {'hillshade-exaggeration': 0.33}
}
],
terrain: {
source: 'terrain',
exaggeration: 1
}
},
maxZoom: 18,
maxPitch: 85
});
maxZoom: 18,
maxPitch: 85
});

map.addControl(new maplibregl.NavigationControl({
visualizePitch: true,
showZoom: true,
showCompass: true
}));
map.addControl(new maplibregl.NavigationControl({
visualizePitch: true,
showZoom: true,
showCompass: true
}));

map.addControl(
new maplibregl.TerrainControl({
source: 'terrain',
exaggeration: 1
})
);
</script>
map.addControl(
new maplibregl.TerrainControl({
source: 'terrain',
Copy link
Copy Markdown
Contributor

@acalcutt acalcutt Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be terrainSource on line 86 , otherwise you can turn terrain off, but can't turn it back on

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style.ts:508 Uncaught Error: cannot load terrain, because there exists no source with ID: terrain
at Style.setTerrain (style.ts:508:37)
at Map.setTerrain (map.ts:1587:20)
at TerrainControl._toggleTerrain (terrain_control.ts:59:23)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch I make a pull request

exaggeration: 1
})
);
</script>
</body>
</html>

</html>