experimental map
[wolnelektury.git] / src / references / templates / references / map.html
diff --git a/src/references/templates/references/map.html b/src/references/templates/references/map.html
new file mode 100644 (file)
index 0000000..6204837
--- /dev/null
@@ -0,0 +1,35 @@
+{% load l10n %}
+
+<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
+   integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
+       crossorigin=""/>
+  <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
+   integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
+          crossorigin=""></script>
+
+<div id="map" style="height: 100%"></div>
+<script>
+  var map = L.map('map').setView([51.505, -0.09], 8);
+  L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
+    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
+  }).addTo(map);
+
+ {% localize off %}
+ {% for e in entities %}
+ L.marker(
+     [{{ e.lat }}, {{ e.lon }}],
+     {
+         title: "{{ e.label }}",
+         alt: "{{ e.label }}",
+     }
+ ).bindPopup("\
+<h1>{{ e.label }}</h1>\
+{% for ref in e.reference_set.all %}\
+<a href='/katalog/lektura/{{ ref.book.slug }}.html#{{ ref.first_section }}'>\
+  {{ ref.book.title }}\
+</a>\
+{% endfor %}\
+ ").addTo(map);
+ {% endfor %}
+ {% endlocalize %}
+</script>