experimental map
[wolnelektury.git] / src / references / templates / references / map.html
1 {% load l10n %}
2
3 <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
4    integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
5        crossorigin=""/>
6   <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
7    integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
8           crossorigin=""></script>
9
10 <div id="map" style="height: 100%"></div>
11 <script>
12   var map = L.map('map').setView([51.505, -0.09], 8);
13   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
14     attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
15   }).addTo(map);
16
17  {% localize off %}
18  {% for e in entities %}
19  L.marker(
20      [{{ e.lat }}, {{ e.lon }}],
21      {
22          title: "{{ e.label }}",
23          alt: "{{ e.label }}",
24      }
25  ).bindPopup("\
26 <h1>{{ e.label }}</h1>\
27 {% for ref in e.reference_set.all %}\
28 <a href='/katalog/lektura/{{ ref.book.slug }}.html#{{ ref.first_section }}'>\
29   {{ ref.book.title }}\
30 </a>\
31 {% endfor %}\
32  ").addTo(map);
33  {% endfor %}
34  {% endlocalize %}
35 </script>