map.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {% extends "layout.html" %}
  2. {% block content %}
  3. <div id="map"></div>
  4. <script type="text/javascript">
  5. var osm = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
  6. maxZoom: 19,
  7. attribution: '© OpenStreetMap'
  8. });
  9. var tileUrl = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
  10. var mapAttribution = '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>';
  11. var map = L.map('map', {
  12. center: [39.73, -104.99],
  13. zoom: 10,
  14. layers: [osm]
  15. });
  16. var baseMaps = {"OpenStreetMap": osm};
  17. var overlayMaps = {};
  18. {% for type, group in marker_groups.items() %}
  19. var grmarkers = [];
  20. var iconSettings = L.AwesomeMarkers.icon({
  21. icon: "{{ group['icon'] }}",
  22. markerColor: "{{ group['color'] }}",
  23. prefix: "fa"
  24. });
  25. {% for marker in group["liste"] %}
  26. var marker = L.marker(
  27. [{{ marker['long'] }}, {{ marker['lat'] }}],
  28. {icon: iconSettings}
  29. ).addTo(map)
  30. .bindPopup("<span class='fw-bold'>{{ marker['name'] }}</span></br> {{marker['shortdescription']}} </br><a href='{{marker['url']}}'>{{marker['url']}}</a>")
  31. .openPopup();
  32. grmarkers.push(marker);
  33. {% endfor %}
  34. var grLayerGr = L.layerGroup(grmarkers);
  35. overlayMaps["<i class='fa fa-{{group['icon']}} me-1' style='color: {{group['color']}}'></i>{{ type }}"] = grLayerGr;
  36. {% endfor %}
  37. var layerControl = L.control.layers(baseMaps, overlayMaps, {collapsed:false, hideSingleBase:true}).addTo(map);
  38. var checkboxes = document.getElementsByTagName("input");
  39. for (var i = 0; i < checkboxes.length; i++) {
  40. if (checkboxes[i].type == "checkbox") {
  41. checkboxes[i].checked = true;
  42. }
  43. }
  44. </script>
  45. {% endblock %}