Update index.html

This commit is contained in:
2024-06-03 11:36:17 -04:00
committed by GitHub
parent d44bef0729
commit 2c3af2516b

View File

@@ -25,14 +25,14 @@
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" /> <link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<!-- Include Leaflet JavaScript --> <!-- Include Leaflet JavaScript -->
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script> <script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<!-- Include KML plugin for Leaflet --> <!-- Include Leaflet Omnivore plugin -->
<script src="https://unpkg.com/leaflet-omnivore"></script> <script src="https://unpkg.com/leaflet-omnivore@0.3.4/leaflet-omnivore.min.js"></script>
</head> </head>
<body> <body>
<div id="map"></div> <div id="map"></div>
<script> <script>
// Initialize the map // Initialize the map centered on New York City
var map = L.map('map').setView([0, 0], 2); var map = L.map('map').setView([40.7128, -74.0060], 12);
// Add OpenStreetMap tiles // Add OpenStreetMap tiles
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
@@ -40,11 +40,14 @@
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map); }).addTo(map);
// Load the KML file // Replace the following URL with your actual KML URL and credentials
omnivore.kml('https://share.garmin.com/Feed/ShareLoader/NDB92').addTo(map); var kmlUrl = 'https://share.garmin.com/Feed/ShareLoader/NDB92';
// Optionally, handle any errors (omnivore doesn't have built-in error handling) // Load the KML file
omnivore.kml('https://share.garmin.com/Feed/ShareLoader/NDB92').on('ready', function() { omnivore.kml(kmlUrl).addTo(map);
// Optionally, handle any errors
omnivore.kml(kmlUrl).on('ready', function() {
console.log('KML loaded successfully'); console.log('KML loaded successfully');
}).on('error', function() { }).on('error', function() {
alert('Failed to load KML'); alert('Failed to load KML');