-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap-leaflet.php
More file actions
65 lines (56 loc) · 1.77 KB
/
map-leaflet.php
File metadata and controls
65 lines (56 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Event Map</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="fonts/inter.css">
<!-- Leaflet CSS and JS -->
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
font-family: 'Inter';
}
#map {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<!--h2>Event Map</h2-->
<div id="map"></div>
<script>
// Initialize the map centered on Schleswig-Holstein
const map = L.map('map').setView([54.3, 9.5], 8);
// Add OpenStreetMap tile layer
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18,
}).addTo(map);
<?php include("config.php"); ?>
const apiUrl = <?php echo json_encode($apiBaseUrl . "/query?mode=event&start=2024-01-01"); ?>;
fetch (apiUrl)
.then(response => response.json())
.then(data => {
const events = data.events || [];
events.forEach(event => {
if (event.venue_lat && event.venue_lon) {
const marker = L.marker([event.venue_lat, event.venue_lon]).addTo(map);
marker.bindPopup(`
<strong>${event.title}</strong><br/>
${event.venue_name}, ${event.venue_city}<br/>
${event.start_date} ${event.start_time || ""}
`);
}
});
})
.catch(error => {
console.error('Error loading events:', error);
});
</script>
</body>
</html>