-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapbox-1.html
More file actions
52 lines (47 loc) · 1.53 KB
/
mapbox-1.html
File metadata and controls
52 lines (47 loc) · 1.53 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mini Mapbox Exercise</title>
<script src='https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.css' rel='stylesheet' />
</head>
<body>
<h1>Fly from SAT International Airport To DFW Airport</h1>
<div id='map' style='width: 800px; height: 600px;'></div>
<button id="zoomIn">+</button>
<button id="zoomOut">-</button>
<script src="js/keys.js"></script>
<script>
mapboxgl.accessToken = MAPBOX_KEY;
const start = [-98.4705371,29.5311973];
const end = [-97.0425239, 32.8998091];
const map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/streets-v11', // style URL
center: start, // starting position [lng, lat] //SAT Airport
// center: [-97.0425239, 32.8998091], // DFW Airport
zoom: 12, // starting zoom
});
setTimeout(function(){
map.flyTo({
center: end,
zoom: 12,
bearing: 0,
speed: .5,
curve: 1,
essential: true
});
map.setStyle('mapbox://styles/mapbox/satellite-streets-v11')
}, 5000)
document.querySelector("#zoomIn").addEventListener('click',function(){
map.setZoom(map.getZoom() + 1);
// or
// map.zoomIn();
})
document.querySelector("#zoomOut").addEventListener('click',function(){
map.setZoom(map.getZoom() - 1);
})
</script>
</body>
</html>