-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaflet_map.html
33 lines (27 loc) · 965 Bytes
/
leaflet_map.html
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
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Map</title>
<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: 1000px;"></div>
<script>
var map = L.map('map').setView([51.9, 4.5], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
// Check if data.results is defined
if (data.results && data.results.bindings) {
// Add markers from the SPARQL query results
data.results.bindings.forEach(function(item) {
var lat = parseFloat(item.lat.value);
var long = parseFloat(item.long.value);
L.marker([lat, long]).addTo(map)
.bindPopup(item.label.value);
});
} else {
console.error("No results found or unexpected data structure.");
}
</script>
</body>
</html>