-
Notifications
You must be signed in to change notification settings - Fork 4
/
3d-playground.html
120 lines (108 loc) · 3.04 KB
/
3d-playground.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html>
<!-- This is basically a stripped-down version of https://github.com/mapbox/mapbox-gl-js/blob/main/debug/3d-playground.html -->
<head>
<title>Mapbox GL JS 3D Playground</title>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no"
/>
<link
href="https://api.mapbox.com/mapbox-gl-js/v2.0.0/mapbox-gl.css"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.5.1/mapbox-gl-geocoder.css"
type="text/css"
/>
<style>
body {
margin: 0;
padding: 0;
}
html,
body,
#map {
height: 100%;
}
.dg.a {
float: left !important;
}
.property-name {
width: 20% !important;
}
</style>
</head>
<body>
<div id="map"></div>
<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.7/dat.gui.min.js"
></script>
<script src="https://api.mapbox.com/mapbox-gl-js/v2.0.0/mapbox-gl.js"></script>
<script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.5.1/mapbox-gl-geocoder.min.js"></script>
<script>
const STYLES = [
"mapbox/satellite-v9",
"mapbox/satellite-streets-v11",
"mapbox/outdoors-v11",
"jseppimbx/ckit0misa1gxw19qkrd4flfda",
];
const startStyle = STYLES[0];
const demo = { style: startStyle };
window.onload = function () {
const gui = new dat.GUI({ width: 320 });
const style = gui.add(demo, "style", STYLES);
style.onFinishChange((value) => {
map.setStyle(`mapbox://styles/${value}`);
});
};
mapboxgl.accessToken =
"pk.eyJ1IjoianNlcHBpbWJ4IiwiYSI6ImNraW9wdWNxdTAyOWQzNG1zMXloOXRhNWoifQ.8rYHD7PVVfW8qme2J-FVVg";
const map = (window.map = new mapboxgl.Map({
container: "map",
zoom: 11.25,
center: [-106.4908, 35.1035],
pitch: 54,
bearing: 0,
style: `mapbox://styles/${demo.style}`,
hash: true,
}));
map.addControl(
new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl,
collapsed: true,
})
);
map.addControl(new mapboxgl.NavigationControl());
map.on("style.load", function () {
map.addSource("mapbox-dem", {
type: "raster-dem",
url: "mapbox://mapbox.terrain-rgb",
tileSize: 512,
maxzoom: 14,
});
map.setTerrain({ source: "mapbox-dem", exaggeration: 2 });
map.addLayer({
id: "sky",
type: "sky",
paint: {
"sky-type": "atmosphere",
"sky-opacity": [
"interpolate",
["exponential", 0.1],
["zoom"],
5,
0,
22,
1,
],
},
});
});
</script>
</body>
</html>