-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap1.html
58 lines (48 loc) · 1.63 KB
/
map1.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Display a map on a webpage</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v2.8.2/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v2.8.2/mapbox-gl.js"></script>
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script src="js/map1.js"></script>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiY2p1NzExIiwiYSI6ImNsM2Q1emV0aTA1OXMzaXFwbWcyanAwMXUifQ.67ZAGBIXYXWd5XvRzNIHtw';
const map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/streets-v11', // style URL
center: [-74.5, 40], // starting position [lng, lat]
zoom: 9 // starting zoom
});
var url = '/findiss';
map.on('load', function() {
window.setInterval(function () {
}, 2000);
map.addSource('iss', {type: 'geojson', data: url});
map.addLayer({
"id": "iss",
"type": "symbol",
"source": "iss",
"layout": {
"icon-image": "rocket-15"
}
});
map.addControl(new mapboxgl.FullscreenControl());
document.getElementById('locate').addEventListener('click', function(e){
var lastSeenLocation = JSON.parse(this.getAttribute('data-coordinate'))
map.flyTo({
center: lastSeenLocation
});
});
});
</script>
</body>
</html>