-
-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Display a hybrid satellite map with terrain elevation</title> | ||
<meta property="og:description" content="Display a hybrid satellite map with terrain elevation." /> | ||
<meta charset='utf-8'> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel='stylesheet' href='../../dist/maplibre-gl.css' /> | ||
<script src='../../dist/maplibre-gl-dev.js'></script> | ||
<style> | ||
body { margin: 0; padding: 0; } | ||
html, body, #map { height: 100%; } | ||
</style> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
<script> | ||
const map = new maplibregl.Map({ | ||
container: 'map', | ||
zoom: 12, | ||
center: [11.39085, 47.27574], | ||
pitch: 70, | ||
maxPitch: 95 | ||
}); | ||
|
||
map.setStyle('https://api.maptiler.com/maps/hybrid/style.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL', { | ||
transformStyle: (previousStyle, nextStyle) => { | ||
nextStyle.sources = { | ||
...nextStyle.sources, terrainSource: { | ||
type: 'raster-dem', | ||
url: 'https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL', | ||
tileSize: 256 | ||
}, | ||
hillshadeSource: { | ||
type: 'raster-dem', | ||
url: 'https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL', | ||
tileSize: 256 | ||
} | ||
} | ||
nextStyle.terrain = { | ||
source: 'terrainSource', | ||
exaggeration: 1 | ||
} | ||
|
||
nextStyle.sky = {} | ||
|
||
nextStyle.layers.push({ | ||
id: 'hills', | ||
type: 'hillshade', | ||
source: 'hillshadeSource', | ||
layout: { visibility: 'visible' }, | ||
paint: { 'hillshade-shadow-color': '#473B24' } | ||
}) | ||
|
||
return nextStyle | ||
} | ||
}) | ||
|
||
map.addControl( | ||
new maplibregl.NavigationControl({ | ||
visualizePitch: true, | ||
showZoom: true, | ||
showCompass: true | ||
}) | ||
); | ||
|
||
map.addControl( | ||
new maplibregl.GlobeControl() | ||
); | ||
|
||
map.addControl( | ||
new maplibregl.TerrainControl({ | ||
source: 'terrainSource', | ||
exaggeration: 1 | ||
}) | ||
); | ||
</script> | ||
</body> | ||
</html> |