-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (50 loc) · 1.78 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display a 3D terrain map</title>
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v1.1.1/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v1.1.1/maptiler-sdk.css" rel="stylesheet" />
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
.mapstyles-select {
position: relative;
top: 5px;
left: 5px;
z-index: 1000;
}
</style>
</head>
<body>
<div id="map"></div>
<select class="mapstyles-select">
<option value="SATELLITE" selected>SATELLITE</option>
<option value="HYBRID">HYBRID</option>
<option value="OUTDOOR">OUTDOOR</option>
<option value="WINTER">WINTER</option>
<option value="TOPO">TOPO</option>
</select>
<script>
maptilersdk.config.apiKey = 'yhy9XyHzzmvrO4bEiJps';
const map = new maptilersdk.Map({
container: 'map', // container's id or the HTML element to render the map
style: maptilersdk.MapStyle.SATELLITE,
center: [-73.05, -51.05], // starting position [lng, lat]
zoom: 12.4, // starting zoom
geolocateControl: false, //disable the geolocate control
terrain: true,
terrainControl: true,
pitch: 85,
bearing: -30,
maxPitch: 85,
maxZoom: 14
});
document.querySelector('.mapstyles-select').addEventListener('change', (e) => {
const style_code = e.target.value.split(".");
style_code.length === 2 ? map.setStyle(maptilersdk.MapStyle[style_code[0]][style_code[1]]) : map.setStyle(maptilersdk.MapStyle[style_code[0]]);
});
</script>
</body>
</html>