-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
174 lines (170 loc) · 5.62 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Start of Async Drift Code -->
<script>
"use strict";
!(function () {
var t = (window.driftt = window.drift = window.driftt || []);
if (!t.init) {
if (t.invoked)
return void (
window.console &&
console.error &&
console.error("Drift snippet included twice.")
);
(t.invoked = !0),
(t.methods = [
"identify",
"config",
"track",
"reset",
"debug",
"show",
"ping",
"page",
"hide",
"off",
"on",
]),
(t.factory = function (e) {
return function () {
var n = Array.prototype.slice.call(arguments);
return n.unshift(e), t.push(n), t;
};
}),
t.methods.forEach(function (e) {
t[e] = t.factory(e);
}),
(t.load = function (t) {
var e = 3e5,
n = Math.ceil(new Date() / e) * e,
o = document.createElement("script");
(o.type = "text/javascript"),
(o.async = !0),
(o.crossorigin = "anonymous"),
(o.src =
"https://js.driftt.com/include/" + n + "/" + t + ".js");
var i = document.getElementsByTagName("script")[0];
i.parentNode.insertBefore(o, i);
});
}
})();
drift.SNIPPET_VERSION = "0.3.1";
drift.load("65nk7afu2fsa");
</script>
<!-- End of Async Drift Code -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link
href="https://fonts.googleapis.com/css?family=Gloria+Hallelujah&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""
/>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script
src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
crossorigin=""
></script>
<style>
body {
height: 100vh;
background-image: url(https://cdn.pixabay.com/photo/2016/02/03/03/23/international-space-station-1176518_1280.jpg);
background-repeat: no-repeat;
background-size: cover;
}
h1 {
color: white;
text-align: center;
font-family: "Gloria Hallelujah", cursive;
margin: auto;
}
#mapid {
margin: auto;
margin-top: 5%;
height: 500px;
width: 500px;
}
@media only screen and (max-width: 460px) {
h1 {
color: white;
text-align: center;
font-family: "Gloria Hallelujah", cursive;
margin: auto;
}
#mapid {
margin-top: 40%;
height: 40%;
width: 95%;
}
body {
background-image: url("https://cdn.pixabay.com/photo/2016/02/03/03/23/international-space-station-1176518_1280.jpg");
background-color: lightblue;
height: 100vh;
}
}
</style>
<title>ISS LIVE</title>
</head>
<body>
<h1>ISS LIVE LOCATION</h1>
<div id="mapid"></div>
<script>
// flag to set view of map for the first time
var flag = 0;
// Icon to be added to the map
var myIcon = L.icon({
iconUrl: "icon.png",
iconSize: [30, 30],
iconAnchor: [25, 16],
});
//Map creation using leaflet.js
const mymap = L.map("mapid").setView([0, 0], 1);
//Marker creation using leaflet.js
const marker = L.marker([0, 0], { icon: myIcon }).addTo(mymap);
//Map tiles and attribution from leaflet.js
L.tileLayer(
"https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}",
{
attribution:
'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: "mapbox/light-v10",
accessToken:
"pk.eyJ1IjoiYXB1cm9vcDIxNDk2IiwiYSI6ImNrNGNrbnpndTBvbDMzZWtkNDRoamU3M3EifQ.TuSVwfUog6YV2giWu-6BQA",
}
).addTo(mymap);
//Function to get ISS cordinates from Open-notify org
async function getCords() {
const response = await fetch(
"https://api.wheretheiss.at/v1/satellites/25544"
);
const latlon = await response.json();
// console.log(latlon);
setMarker(latlon);
}
//Function for setting View of the map and view of marker after getting the data
function setMarker(data) {
let latitude = data["latitude"];
let longitude = data["longitude"];
// console.log(data);
if (flag == 0) {
mymap.setView([latitude, longitude], 3);
flag = 1;
}
marker
.setLatLng([latitude, longitude])
.bindPopup(`Latitude: ${latitude} <br> Longitude:${longitude}`);
}
//Calling the IIS cordinates function again and again after 2 seconds two update state of ISS
setInterval(getCords, 5000);
</script>
</body>
</html>