map.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. {% extends "layout.html" %}
  2. {% block head_links %}
  3. <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js" integrity="sha512-rmZcZsyhe0/MAjquhTgiUcb4d9knaFc7b5xAfju483gbEXTkeJRUMIPk6s3ySZMYUHEcjKbjLjyddGWMrNEvZg==" crossorigin="anonymous"></script>
  4. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
  5. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
  6. integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
  7. crossorigin=""/>
  8. <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
  9. integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
  10. crossorigin=""></script>
  11. <link rel="stylesheet" href="static/css/leaflet.awesome-markers.css">
  12. <script src="static/js/leaflet.awesome-markers.js"></script>
  13. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  14. {% endblock %}
  15. {% block content %}
  16. <div id="map"></div>
  17. <script type="text/javascript">
  18. var osm = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
  19. maxZoom: 19,
  20. attribution: '© OpenStreetMap'
  21. });
  22. var tileUrl = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
  23. var mapAttribution = '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>';
  24. var map = L.map('map', {
  25. center: [39.73, -104.99],
  26. zoom: 10,
  27. layers: [osm]
  28. });
  29. var baseMaps = {"OpenStreetMap": osm};
  30. var overlayMaps = {};
  31. {% for type, group in marker_groups.items() %}
  32. var grmarkers = [];
  33. var iconSettings = L.AwesomeMarkers.icon({
  34. icon: "{{ group['icon'] }}",
  35. markerColor: "{{ group['color'] }}",
  36. prefix: "fa"
  37. });
  38. {% for marker in group["liste"] %}
  39. var marker = L.marker(
  40. [{{ marker['long'] }}, {{ marker['lat'] }}],
  41. {icon: iconSettings}
  42. ).addTo(map)
  43. .bindPopup("<span class='fw-bold'>{{ marker['name'] }}</span></br> {{marker['shortdescription']}} </br><a href='{{marker['url']}}'>{{marker['url']}}</a>")
  44. .openPopup();
  45. grmarkers.push(marker);
  46. {% endfor %}
  47. var grLayerGr = L.layerGroup(grmarkers);
  48. overlayMaps["<i class='fa fa-{{group['icon']}} me-1' style='color: {{group['color']}}'></i>{{ type }}"] = grLayerGr;
  49. {% endfor %}
  50. var layerControl = L.control.layers(baseMaps, overlayMaps, {collapsed:false, hideSingleBase:true}).addTo(map);
  51. var checkboxes = document.getElementsByTagName("input");
  52. for (var i = 0; i < checkboxes.length; i++) {
  53. if (checkboxes[i].type == "checkbox") {
  54. checkboxes[i].checked = true;
  55. }
  56. }
  57. </script>
  58. {% endblock %}