code
Snippet
language
CDN
package_2
NPM
content_copy
Copy
open_in_new
Open
const map = new maplibregl. Map ({
container: 'map' ,
style: 'https://api.maptiler.com/maps/outdoor-v4/style.json?key=YOUR_MAPTILER_KEY' ,
center: [ 7.66 , 45.98 ],
zoom: 12 ,
pitch: 60 ,
bearing: - 20 ,
maxPitch: 85
});
map. addControl ( new maplibregl. NavigationControl ());
map. on ( 'load' , () => {
map. addSource ( 'terrain-dem' , {
type: 'raster-dem' ,
url: 'https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key=YOUR_MAPTILER_KEY' ,
tileSize: 256
});
map. setTerrain ({ source: 'terrain-dem' , exaggeration: 1.5 });
map. setSky ({
'sky-color' : '#199EF3' ,
'horizon-color' : '#ffffff' ,
'fog-color' : '#ffffff' ,
'sky-horizon-blend' : 0.5 ,
'horizon-fog-blend' : 0.5 ,
'fog-ground-blend' : 0.5 ,
'atmosphere-blend' : [ 'interpolate' , [ 'linear' ], [ 'zoom' ], 0 , 1 , 10 , 1 , 12 , 0 ]
});
}); content_copy
Copy
open_in_new
Open
<! doctype html >
< html lang = "en" >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title >3D Terrain with MapLibre GL JS</ title >
< link rel = "stylesheet" href = "https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl.css" >
< style >
body { margin : 0 ; padding : 0 ; }
#map { width : 100 % ; height : 100 vh ; }
</ style >
</ head >
< body >
< div id = "map" ></ div >
< script type = "module" >
import * as maplibregl from 'https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl.mjs' ;
const map = new maplibregl. Map ({
container: 'map' ,
style: 'https://api.maptiler.com/maps/outdoor-v4/style.json?key=YOUR_MAPTILER_KEY' ,
center: [ 7.66 , 45.98 ],
zoom: 12 ,
pitch: 60 ,
bearing: - 20 ,
maxPitch: 85
});
map. addControl ( new maplibregl. NavigationControl ());
map. on ( 'load' , () => {
map. addSource ( 'terrain-dem' , {
type: 'raster-dem' ,
url: 'https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key=YOUR_MAPTILER_KEY' ,
tileSize: 256
});
map. setTerrain ({ source: 'terrain-dem' , exaggeration: 1.5 });
map. setSky ({
'sky-color' : '#199EF3' ,
'horizon-color' : '#ffffff' ,
'fog-color' : '#ffffff' ,
'sky-horizon-blend' : 0.5 ,
'horizon-fog-blend' : 0.5 ,
'fog-ground-blend' : 0.5 ,
'atmosphere-blend' : [ 'interpolate' , [ 'linear' ], [ 'zoom' ], 0 , 1 , 10 , 1 , 12 , 0 ]
});
});
</ script >
</ body >
</ html > content_copy
Copy
open_in_new
Open
import maplibregl from 'maplibre-gl' ;
import 'maplibre-gl/dist/maplibre-gl.css' ;
const map = new maplibregl. Map ({
container: 'map' ,
style: 'https://api.maptiler.com/maps/outdoor-v4/style.json?key=YOUR_MAPTILER_KEY' ,
center: [ 7.66 , 45.98 ],
zoom: 12 ,
pitch: 60 ,
bearing: - 20 ,
maxPitch: 85
});
map. addControl ( new maplibregl. NavigationControl ());
map. on ( 'load' , () => {
map. addSource ( 'terrain-dem' , {
type: 'raster-dem' ,
url: 'https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key=YOUR_MAPTILER_KEY' ,
tileSize: 256
});
map. setTerrain ({ source: 'terrain-dem' , exaggeration: 1.5 });
map. setSky ({
'sky-color' : '#199EF3' ,
'horizon-color' : '#ffffff' ,
'fog-color' : '#ffffff' ,
'sky-horizon-blend' : 0.5 ,
'horizon-fog-blend' : 0.5 ,
'fog-ground-blend' : 0.5 ,
'atmosphere-blend' : [ 'interpolate' , [ 'linear' ], [ 'zoom' ], 0 , 1 , 10 , 1 , 12 , 0 ]
});
});
const map = new maplibregl.Map({
container: 'map',
style: 'https://api.maptiler.com/maps/outdoor-v4/style.json?key=YOUR_MAPTILER_KEY',
center: [7.66, 45.98],
zoom: 12,
pitch: 60,
bearing: -20,
maxPitch: 85
});
map.addControl(new maplibregl.NavigationControl());
map.on('load', () => {
map.addSource('terrain-dem', {
type: 'raster-dem',
url: 'https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key=YOUR_MAPTILER_KEY',
tileSize: 256
});
map.setTerrain({ source: 'terrain-dem', exaggeration: 1.5 });
map.setSky({
'sky-color': '#199EF3',
'horizon-color': '#ffffff',
'fog-color': '#ffffff',
'sky-horizon-blend': 0.5,
'horizon-fog-blend': 0.5,
'fog-ground-blend': 0.5,
'atmosphere-blend': ['interpolate', ['linear'], ['zoom'], 0, 1, 10, 1, 12, 0]
});
}); <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Terrain with MapLibre GL JS</title>
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl.css">
<style>
body { margin: 0; padding: 0; }
#map { width: 100%; height: 100vh; }
</style>
</head>
<body>
<div id="map"></div>
<script type="module">
import * as maplibregl from 'https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl.mjs';
const map = new maplibregl.Map({
container: 'map',
style: 'https://api.maptiler.com/maps/outdoor-v4/style.json?key=YOUR_MAPTILER_KEY',
center: [7.66, 45.98],
zoom: 12,
pitch: 60,
bearing: -20,
maxPitch: 85
});
map.addControl(new maplibregl.NavigationControl());
map.on('load', () => {
map.addSource('terrain-dem', {
type: 'raster-dem',
url: 'https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key=YOUR_MAPTILER_KEY',
tileSize: 256
});
map.setTerrain({ source: 'terrain-dem', exaggeration: 1.5 });
map.setSky({
'sky-color': '#199EF3',
'horizon-color': '#ffffff',
'fog-color': '#ffffff',
'sky-horizon-blend': 0.5,
'horizon-fog-blend': 0.5,
'fog-ground-blend': 0.5,
'atmosphere-blend': ['interpolate', ['linear'], ['zoom'], 0, 1, 10, 1, 12, 0]
});
});
</script>
</body>
</html> import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
const map = new maplibregl.Map({
container: 'map',
style: 'https://api.maptiler.com/maps/outdoor-v4/style.json?key=YOUR_MAPTILER_KEY',
center: [7.66, 45.98],
zoom: 12,
pitch: 60,
bearing: -20,
maxPitch: 85
});
map.addControl(new maplibregl.NavigationControl());
map.on('load', () => {
map.addSource('terrain-dem', {
type: 'raster-dem',
url: 'https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key=YOUR_MAPTILER_KEY',
tileSize: 256
});
map.setTerrain({ source: 'terrain-dem', exaggeration: 1.5 });
map.setSky({
'sky-color': '#199EF3',
'horizon-color': '#ffffff',
'fog-color': '#ffffff',
'sky-horizon-blend': 0.5,
'horizon-fog-blend': 0.5,
'fog-ground-blend': 0.5,
'atmosphere-blend': ['interpolate', ['linear'], ['zoom'], 0, 1, 10, 1, 12, 0]
});
});
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Terrain with MapLibre GL JS</title>
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl.css">
<style>
body { margin: 0; padding: 0; }
#map { width: 100%; height: 100vh; }
</style>
</head>
<body>
<div id="map"></div>
<script type="module">
import * as maplibregl from 'https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl.mjs';
window.maplibregl = maplibregl;
const map = new maplibregl.Map({
container: 'map',
style: 'https://api.maptiler.com/maps/outdoor-v4/style.json?key=LKv9WPh4aJggV1CHU4Y8',
center: [7.66, 45.98],
zoom: 12,
pitch: 60,
bearing: -20,
maxPitch: 85
});
map.addControl(new maplibregl.NavigationControl());
map.on('load', () => {
map.addSource('terrain-dem', {
type: 'raster-dem',
url: 'https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key=LKv9WPh4aJggV1CHU4Y8',
tileSize: 256
});
map.setTerrain({ source: 'terrain-dem', exaggeration: 1.5 });
map.setSky({
'sky-color': '#199EF3',
'horizon-color': '#ffffff',
'fog-color': '#ffffff',
'sky-horizon-blend': 0.5,
'horizon-fog-blend': 0.5,
'fog-ground-blend': 0.5,
'atmosphere-blend': ['interpolate', ['linear'], ['zoom'], 0, 1, 10, 1, 12, 0]
});
});
</script>
</body>
</html>