mirror of
https://github.com/sstent/StuTracker.git
synced 2026-01-26 10:32:24 +00:00
63 lines
2.0 KiB
HTML
63 lines
2.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>OpenStreetMap with KML Data</title>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<style>
|
|
/* Ensure the map container takes up the full page */
|
|
#map {
|
|
height: 100%;
|
|
width: 100%;
|
|
position: absolute;
|
|
top: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
}
|
|
html, body {
|
|
height: 100%;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
</style>
|
|
<!-- Include Leaflet CSS -->
|
|
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
|
|
<!-- Include Leaflet JavaScript -->
|
|
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
|
|
<!-- Include Leaflet Omnivore plugin -->
|
|
<script src="https://unpkg.com/leaflet-omnivore@0.3.4/leaflet-omnivore.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="map"></div>
|
|
<script>
|
|
// Initialize the map centered on New York City
|
|
var map = L.map('map').setView([40.7128, -74.0060], 12);
|
|
|
|
// Add OpenStreetMap tiles
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
maxZoom: 19,
|
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
}).addTo(map);
|
|
|
|
// KML URL with username and password
|
|
var kmlUrl = 'https://USERNAME:abodyinmotion@share.garmin.com/Feed/ShareLoader/NDB92';
|
|
|
|
|
|
// Use CorsProxy.io
|
|
var corsProxy = 'https://corsproxy.io/?';
|
|
var proxyKmlUrl = corsProxy + encodeURIComponent(kmlUrl);
|
|
|
|
// Load the KML file
|
|
omnivore.kml(proxyKmlUrl).addTo(map);
|
|
|
|
// Optionally, handle any errors
|
|
omnivore.kml(proxyKmlUrl).on('ready', function() {
|
|
console.log('KML loaded successfully');
|
|
}).on('error', function() {
|
|
alert('Failed to load KML');
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|