forked from sksalahuddin2828/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3D Earth Rotation.html
52 lines (44 loc) · 1.33 KB
/
3D Earth Rotation.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>3D Earth Rotation</title>
<style>
#map {
width: 800px;
height: 600px;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css" />
</head>
<body>
<div id="map"></div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>
<script>
const map = L.map('map', {
center: [0, 0],
zoom: 1,
worldCopyJump: true
});
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
const marker = L.marker([0, 0]).addTo(map);
// Add other coastlines as markers as needed
function rotateEarth() {
let frame = 0;
const frameCount = 180;
const rotationInterval = 20;
function updateRotation() {
marker.setRotationAngle(frame);
frame += 2;
if (frame > 360) {
frame = 0;
}
}
setInterval(updateRotation, rotationInterval);
}
rotateEarth();
</script>
</body>
</html>