Update index.html
Browse files- index.html +32 -40
index.html
CHANGED
|
@@ -8,11 +8,11 @@
|
|
| 8 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 9 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js"></script>
|
| 10 |
<style>
|
| 11 |
-
html,
|
| 12 |
-
body {
|
| 13 |
width: 100%;
|
| 14 |
height: 100%;
|
| 15 |
margin: 0;
|
|
|
|
| 16 |
}
|
| 17 |
|
| 18 |
.map-container {
|
|
@@ -20,35 +20,32 @@
|
|
| 20 |
height: 900px;
|
| 21 |
position: relative;
|
| 22 |
background-image: url('./map-bg.png');
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
|
| 25 |
-
|
| 26 |
-
width: 100%;
|
| 27 |
-
height: 100%;
|
| 28 |
-
background-image: url('./map.png');
|
| 29 |
-
mix-blend-mode: multiply;
|
| 30 |
-
filter: grayscale(1);
|
| 31 |
-
position: relative;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
.map .mask {
|
| 35 |
width: 100%;
|
| 36 |
height: 100%;
|
| 37 |
-
background-image: url("./cloud.png");
|
| 38 |
-
mix-blend-mode: lighten;
|
| 39 |
-
animation: 3s linear 0s magic forwards;
|
| 40 |
position: absolute;
|
| 41 |
top: 0;
|
| 42 |
left: 0;
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
width: 100%;
|
| 47 |
height: 100%;
|
|
|
|
|
|
|
|
|
|
| 48 |
position: absolute;
|
| 49 |
top: 0;
|
| 50 |
left: 0;
|
| 51 |
-
background: transparent;
|
| 52 |
}
|
| 53 |
|
| 54 |
.track {
|
|
@@ -98,12 +95,10 @@
|
|
| 98 |
0% {
|
| 99 |
opacity: 0;
|
| 100 |
}
|
| 101 |
-
|
| 102 |
25% {
|
| 103 |
opacity: 1;
|
| 104 |
filter: brightness(1);
|
| 105 |
}
|
| 106 |
-
|
| 107 |
100% {
|
| 108 |
opacity: 1;
|
| 109 |
filter: brightness(10);
|
|
@@ -118,31 +113,24 @@
|
|
| 118 |
0% {
|
| 119 |
background-position-x: 0px;
|
| 120 |
}
|
| 121 |
-
|
| 122 |
25% {
|
| 123 |
background-position-x: 0px;
|
| 124 |
}
|
| 125 |
-
|
| 126 |
25.1% {
|
| 127 |
background-position-x: -10px;
|
| 128 |
}
|
| 129 |
-
|
| 130 |
50% {
|
| 131 |
background-position-x: -10px;
|
| 132 |
}
|
| 133 |
-
|
| 134 |
50.1% {
|
| 135 |
background-position-x: -20px;
|
| 136 |
}
|
| 137 |
-
|
| 138 |
75% {
|
| 139 |
background-position-x: -20px;
|
| 140 |
}
|
| 141 |
-
|
| 142 |
75.1% {
|
| 143 |
background-position-x: -30px;
|
| 144 |
}
|
| 145 |
-
|
| 146 |
100% {
|
| 147 |
background-position-x: -30px;
|
| 148 |
}
|
|
@@ -161,12 +149,17 @@
|
|
| 161 |
}
|
| 162 |
|
| 163 |
@keyframes magic {
|
| 164 |
-
|
| 165 |
filter: brightness(10);
|
|
|
|
| 166 |
}
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
| 169 |
filter: brightness(0);
|
|
|
|
| 170 |
}
|
| 171 |
}
|
| 172 |
|
|
@@ -179,16 +172,17 @@
|
|
| 179 |
background-size: 160px 40px;
|
| 180 |
text-align: center;
|
| 181 |
line-height: 30px;
|
| 182 |
-
font-family: 'Apple Chancery';
|
| 183 |
z-index: 1000;
|
| 184 |
animation: 1s linear 0s nameShow forwards;
|
|
|
|
|
|
|
| 185 |
}
|
| 186 |
|
| 187 |
@keyframes nameShow {
|
| 188 |
from {
|
| 189 |
opacity: 0;
|
| 190 |
}
|
| 191 |
-
|
| 192 |
to {
|
| 193 |
opacity: 1;
|
| 194 |
}
|
|
@@ -211,6 +205,7 @@
|
|
| 211 |
border: 1px solid #8b4513;
|
| 212 |
border-radius: 4px;
|
| 213 |
font-family: 'Apple Chancery', cursive;
|
|
|
|
| 214 |
}
|
| 215 |
|
| 216 |
.user-controls button {
|
|
@@ -221,10 +216,11 @@
|
|
| 221 |
border-radius: 4px;
|
| 222 |
cursor: pointer;
|
| 223 |
font-family: 'Apple Chancery', cursive;
|
|
|
|
| 224 |
}
|
| 225 |
|
| 226 |
-
.
|
| 227 |
-
background:
|
| 228 |
}
|
| 229 |
|
| 230 |
.leaflet-control-attribution {
|
|
@@ -232,7 +228,6 @@
|
|
| 232 |
}
|
| 233 |
</style>
|
| 234 |
</head>
|
| 235 |
-
|
| 236 |
<body>
|
| 237 |
<div class="map-container">
|
| 238 |
<div class="map">
|
|
@@ -254,7 +249,7 @@
|
|
| 254 |
let otherUsers = {};
|
| 255 |
let lastPosition = null;
|
| 256 |
let lastUpdateTime = 0;
|
| 257 |
-
const updateInterval = 1000;
|
| 258 |
|
| 259 |
function initSocket() {
|
| 260 |
socket = io();
|
|
@@ -293,6 +288,7 @@
|
|
| 293 |
}
|
| 294 |
|
| 295 |
function getAngle(p0, p1) {
|
|
|
|
| 296 |
const deltaX = p1.lng - p0.lng;
|
| 297 |
const deltaY = p1.lat - p0.lat;
|
| 298 |
return Math.atan2(deltaY, deltaX);
|
|
@@ -377,7 +373,6 @@
|
|
| 377 |
}
|
| 378 |
}
|
| 379 |
|
| 380 |
-
// 移除已断开连接的用户
|
| 381 |
for (const name of Object.keys(otherUsers)) {
|
| 382 |
if (!users[name]) {
|
| 383 |
map.removeLayer(otherUsers[name]);
|
|
@@ -412,15 +407,13 @@
|
|
| 412 |
map = L.map('leaflet-map', {
|
| 413 |
center: [39.9042, 116.4074],
|
| 414 |
zoom: 16,
|
| 415 |
-
zoomControl: false
|
| 416 |
-
attributionControl: false
|
| 417 |
});
|
| 418 |
|
| 419 |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
| 420 |
maxZoom: 19
|
| 421 |
}).addTo(map);
|
| 422 |
|
| 423 |
-
// 等待cloud.png动画结束后开始初始化其他功能
|
| 424 |
const mapMask = document.getElementById('mapMask');
|
| 425 |
mapMask.addEventListener('animationend', () => {
|
| 426 |
initSocket();
|
|
@@ -437,7 +430,6 @@
|
|
| 437 |
});
|
| 438 |
}
|
| 439 |
|
| 440 |
-
// 启动应用
|
| 441 |
initMap();
|
| 442 |
</script>
|
| 443 |
</body>
|
|
|
|
| 8 |
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
| 9 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js"></script>
|
| 10 |
<style>
|
| 11 |
+
html, body {
|
|
|
|
| 12 |
width: 100%;
|
| 13 |
height: 100%;
|
| 14 |
margin: 0;
|
| 15 |
+
background: #000;
|
| 16 |
}
|
| 17 |
|
| 18 |
.map-container {
|
|
|
|
| 20 |
height: 900px;
|
| 21 |
position: relative;
|
| 22 |
background-image: url('./map-bg.png');
|
| 23 |
+
background-size: cover;
|
| 24 |
+
background-position: center;
|
| 25 |
}
|
| 26 |
|
| 27 |
+
#leaflet-map {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
width: 100%;
|
| 29 |
height: 100%;
|
|
|
|
|
|
|
|
|
|
| 30 |
position: absolute;
|
| 31 |
top: 0;
|
| 32 |
left: 0;
|
| 33 |
+
background: transparent;
|
| 34 |
}
|
| 35 |
|
| 36 |
+
.leaflet-tile-container img {
|
| 37 |
+
opacity: 0.15 !important;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.map .mask {
|
| 41 |
width: 100%;
|
| 42 |
height: 100%;
|
| 43 |
+
background-image: url("./cloud.png");
|
| 44 |
+
mix-blend-mode: lighten;
|
| 45 |
+
animation: 8s linear 0s magic forwards;
|
| 46 |
position: absolute;
|
| 47 |
top: 0;
|
| 48 |
left: 0;
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
.track {
|
|
|
|
| 95 |
0% {
|
| 96 |
opacity: 0;
|
| 97 |
}
|
|
|
|
| 98 |
25% {
|
| 99 |
opacity: 1;
|
| 100 |
filter: brightness(1);
|
| 101 |
}
|
|
|
|
| 102 |
100% {
|
| 103 |
opacity: 1;
|
| 104 |
filter: brightness(10);
|
|
|
|
| 113 |
0% {
|
| 114 |
background-position-x: 0px;
|
| 115 |
}
|
|
|
|
| 116 |
25% {
|
| 117 |
background-position-x: 0px;
|
| 118 |
}
|
|
|
|
| 119 |
25.1% {
|
| 120 |
background-position-x: -10px;
|
| 121 |
}
|
|
|
|
| 122 |
50% {
|
| 123 |
background-position-x: -10px;
|
| 124 |
}
|
|
|
|
| 125 |
50.1% {
|
| 126 |
background-position-x: -20px;
|
| 127 |
}
|
|
|
|
| 128 |
75% {
|
| 129 |
background-position-x: -20px;
|
| 130 |
}
|
|
|
|
| 131 |
75.1% {
|
| 132 |
background-position-x: -30px;
|
| 133 |
}
|
|
|
|
| 134 |
100% {
|
| 135 |
background-position-x: -30px;
|
| 136 |
}
|
|
|
|
| 149 |
}
|
| 150 |
|
| 151 |
@keyframes magic {
|
| 152 |
+
0% {
|
| 153 |
filter: brightness(10);
|
| 154 |
+
opacity: 1;
|
| 155 |
}
|
| 156 |
+
70% {
|
| 157 |
+
filter: brightness(8);
|
| 158 |
+
opacity: 1;
|
| 159 |
+
}
|
| 160 |
+
100% {
|
| 161 |
filter: brightness(0);
|
| 162 |
+
opacity: 0;
|
| 163 |
}
|
| 164 |
}
|
| 165 |
|
|
|
|
| 172 |
background-size: 160px 40px;
|
| 173 |
text-align: center;
|
| 174 |
line-height: 30px;
|
| 175 |
+
font-family: 'Apple Chancery', cursive;
|
| 176 |
z-index: 1000;
|
| 177 |
animation: 1s linear 0s nameShow forwards;
|
| 178 |
+
color: #3c2a1e;
|
| 179 |
+
text-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
|
| 180 |
}
|
| 181 |
|
| 182 |
@keyframes nameShow {
|
| 183 |
from {
|
| 184 |
opacity: 0;
|
| 185 |
}
|
|
|
|
| 186 |
to {
|
| 187 |
opacity: 1;
|
| 188 |
}
|
|
|
|
| 205 |
border: 1px solid #8b4513;
|
| 206 |
border-radius: 4px;
|
| 207 |
font-family: 'Apple Chancery', cursive;
|
| 208 |
+
background: rgba(255, 255, 255, 0.9);
|
| 209 |
}
|
| 210 |
|
| 211 |
.user-controls button {
|
|
|
|
| 216 |
border-radius: 4px;
|
| 217 |
cursor: pointer;
|
| 218 |
font-family: 'Apple Chancery', cursive;
|
| 219 |
+
transition: background-color 0.3s;
|
| 220 |
}
|
| 221 |
|
| 222 |
+
.user-controls button:hover {
|
| 223 |
+
background: #654321;
|
| 224 |
}
|
| 225 |
|
| 226 |
.leaflet-control-attribution {
|
|
|
|
| 228 |
}
|
| 229 |
</style>
|
| 230 |
</head>
|
|
|
|
| 231 |
<body>
|
| 232 |
<div class="map-container">
|
| 233 |
<div class="map">
|
|
|
|
| 249 |
let otherUsers = {};
|
| 250 |
let lastPosition = null;
|
| 251 |
let lastUpdateTime = 0;
|
| 252 |
+
const updateInterval = 1000;
|
| 253 |
|
| 254 |
function initSocket() {
|
| 255 |
socket = io();
|
|
|
|
| 288 |
}
|
| 289 |
|
| 290 |
function getAngle(p0, p1) {
|
| 291 |
+
if (!p0 || !p1) return 0;
|
| 292 |
const deltaX = p1.lng - p0.lng;
|
| 293 |
const deltaY = p1.lat - p0.lat;
|
| 294 |
return Math.atan2(deltaY, deltaX);
|
|
|
|
| 373 |
}
|
| 374 |
}
|
| 375 |
|
|
|
|
| 376 |
for (const name of Object.keys(otherUsers)) {
|
| 377 |
if (!users[name]) {
|
| 378 |
map.removeLayer(otherUsers[name]);
|
|
|
|
| 407 |
map = L.map('leaflet-map', {
|
| 408 |
center: [39.9042, 116.4074],
|
| 409 |
zoom: 16,
|
| 410 |
+
zoomControl: false
|
|
|
|
| 411 |
});
|
| 412 |
|
| 413 |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
| 414 |
maxZoom: 19
|
| 415 |
}).addTo(map);
|
| 416 |
|
|
|
|
| 417 |
const mapMask = document.getElementById('mapMask');
|
| 418 |
mapMask.addEventListener('animationend', () => {
|
| 419 |
initSocket();
|
|
|
|
| 430 |
});
|
| 431 |
}
|
| 432 |
|
|
|
|
| 433 |
initMap();
|
| 434 |
</script>
|
| 435 |
</body>
|