-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" /> | ||
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script> | ||
</head> | ||
<body> | ||
<div id="map" style="height:500px"></div> | ||
<script> | ||
(function() { | ||
const map = L.map('map').setView([34, -170], 1); | ||
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', { | ||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' | ||
}).addTo(map); | ||
|
||
let laMarker = L.marker([34.0522, -118.2437], { | ||
icon: L.divIcon({ | ||
className: 'time-label', | ||
html: 'Loading...', | ||
}), | ||
}).addTo(map); // Los Angeles | ||
setInterval(() => { | ||
let laTime = new Intl.DateTimeFormat('en-US', { timeZone: 'America/Los_Angeles', timeStyle: 'medium' }).format(new Date()); | ||
laMarker.setIcon(L.divIcon({ | ||
className: 'time-label', | ||
html: '<p> 🇺🇸 ' + laTime + '</p>', | ||
})); | ||
}, 1000); | ||
|
||
let tokyoMarker = L.marker([35.6895, 139.6917 - 360], { | ||
icon: L.divIcon({ | ||
className: 'time-label', | ||
html: 'Loading...', | ||
}), | ||
}).addTo(map); // Tokyo, Japan | ||
setInterval(() => { | ||
let tokyoTime = new Intl.DateTimeFormat('en-US', { timeZone: 'Asia/Tokyo', timeStyle: 'medium' }).format(new Date()); | ||
tokyoMarker.setIcon(L.divIcon({ | ||
className: 'time-label', | ||
html: '<p>🇯🇵 ' + tokyoTime + '</p>', | ||
})); | ||
}, 1000); | ||
})(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Show some timezones on a map</title> | ||
<meta property="og:description" content="Show some timezones on a map" /> | ||
<meta charset='utf-8'> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel='stylesheet' href='https://unpkg.com/[email protected]/dist/maplibre-gl.css' /> | ||
<script src='https://unpkg.com/[email protected]/dist/maplibre-gl.js'></script> | ||
<style> | ||
body { margin: 0; padding: 0; } | ||
html, body, #map { height: 100%; } | ||
.maplibregl-popup { | ||
background-color: transparent; | ||
box-shadow: none; | ||
} | ||
.maplibregl-popup-content { | ||
background-color: transparent; | ||
color: #000; | ||
box-shadow: none; | ||
padding: 0; | ||
} | ||
.maplibregl-popup-tip { | ||
display: none; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
|
||
<script> | ||
const map = new maplibregl.Map({ | ||
container: 'map', | ||
style: 'https://basemaps.cartocdn.com/gl/positron-nolabels-gl-style/style.json', | ||
center: [170, 32], | ||
zoom: 1 | ||
}); | ||
|
||
map.on('load', function () { | ||
const laPopup = new maplibregl.Popup({ offset: 25, closeOnClick: false, closeButton: false }) | ||
.setLngLat([-118.2437, 34.0522]) | ||
.setText('🇺🇸 Loading...') | ||
.addTo(map); | ||
|
||
const tokyoPopup = new maplibregl.Popup({ offset: 25, closeOnClick: false, closeButton: false }) | ||
.setLngLat([139.6917, 35.6895]) | ||
.setText('🇯🇵 Loading...') | ||
.addTo(map); | ||
|
||
// Update the labels every second. | ||
setInterval(() => { | ||
let laTime = new Intl.DateTimeFormat('en-US', { timeZone: 'America/Los_Angeles', timeStyle: 'medium' }).format(new Date()); | ||
let tokyoTime = new Intl.DateTimeFormat('en-US', { timeZone: 'Asia/Tokyo', timeStyle: 'medium' }).format(new Date()); | ||
|
||
laPopup.setText('🇺🇸 ' + laTime); | ||
tokyoPopup.setText('🇯🇵 ' + tokyoTime); | ||
}, 1000); | ||
}); | ||
</script> | ||
</body> | ||
</html> |