mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 17:51:08 -05:00
Add version control context processor and integrate map functionality with dedicated JavaScript
This commit is contained in:
20
static/js/map-init.js
Normal file
20
static/js/map-init.js
Normal file
@@ -0,0 +1,20 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const mapContainer = document.getElementById('map');
|
||||
if (!mapContainer) return;
|
||||
|
||||
const lat = parseFloat(mapContainer.dataset.lat);
|
||||
const lng = parseFloat(mapContainer.dataset.lng);
|
||||
const name = mapContainer.dataset.name;
|
||||
|
||||
if (isNaN(lat) || isNaN(lng)) return;
|
||||
|
||||
const map = L.map('map').setView([lat, lng], 13);
|
||||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© OpenStreetMap contributors'
|
||||
}).addTo(map);
|
||||
|
||||
L.marker([lat, lng])
|
||||
.addTo(map)
|
||||
.bindPopup(name);
|
||||
});
|
||||
Reference in New Issue
Block a user