diff --git a/wheretogo/static/img/about.txt b/wheretogo/static/common/img/about.txt similarity index 100% rename from wheretogo/static/img/about.txt rename to wheretogo/static/common/img/about.txt diff --git a/wheretogo/static/img/android-chrome-192x192.png b/wheretogo/static/common/img/android-chrome-192x192.png similarity index 100% rename from wheretogo/static/img/android-chrome-192x192.png rename to wheretogo/static/common/img/android-chrome-192x192.png diff --git a/wheretogo/static/img/android-chrome-512x512.png b/wheretogo/static/common/img/android-chrome-512x512.png similarity index 100% rename from wheretogo/static/img/android-chrome-512x512.png rename to wheretogo/static/common/img/android-chrome-512x512.png diff --git a/wheretogo/static/img/apple-touch-icon.png b/wheretogo/static/common/img/apple-touch-icon.png similarity index 100% rename from wheretogo/static/img/apple-touch-icon.png rename to wheretogo/static/common/img/apple-touch-icon.png diff --git a/wheretogo/static/img/favicon-16x16.png b/wheretogo/static/common/img/favicon-16x16.png similarity index 100% rename from wheretogo/static/img/favicon-16x16.png rename to wheretogo/static/common/img/favicon-16x16.png diff --git a/wheretogo/static/img/favicon-32x32.png b/wheretogo/static/common/img/favicon-32x32.png similarity index 100% rename from wheretogo/static/img/favicon-32x32.png rename to wheretogo/static/common/img/favicon-32x32.png diff --git a/wheretogo/static/img/favicon.ico b/wheretogo/static/common/img/favicon.ico similarity index 100% rename from wheretogo/static/img/favicon.ico rename to wheretogo/static/common/img/favicon.ico diff --git a/wheretogo/static/img/site.webmanifest b/wheretogo/static/common/img/site.webmanifest similarity index 100% rename from wheretogo/static/img/site.webmanifest rename to wheretogo/static/common/img/site.webmanifest diff --git a/wheretogo/static/css/map.css b/wheretogo/static/maps/css/map.css similarity index 100% rename from wheretogo/static/css/map.css rename to wheretogo/static/maps/css/map.css diff --git a/wheretogo/static/maps/js/map.js b/wheretogo/static/maps/js/map.js new file mode 100644 index 0000000..811db13 --- /dev/null +++ b/wheretogo/static/maps/js/map.js @@ -0,0 +1,24 @@ +const copy = "© OpenStreetMap contributors"; +const url = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"; +const osm = L.tileLayer(url, { attribution: copy }); +const map = L.map("map", { layers: [osm], minZoom: 5 }); +map. + locate() + .on("locationfound", (e) => map.setView(e.latlng, 8)) + .on("locationerror", () => map.setView([0, 0], 5)); + +async function load_facilities() { + const facilities_url = `/api/facilities/?in_bbox=${map.getBounds().toBBoxString()}` + const response = await fetch(facilities_url) + const geojson = await response.json() + return geojson +} + +async function render_facilities() { + const facilities = await load_facilities(); + L.geoJSON(facilities) + .bindPopup((layer) => layer.feature.properties.name) + .addTo(map); +} + +map.on("moveend", render_facilities); diff --git a/wheretogo/templates/common/base.html b/wheretogo/templates/common/base.html index 76ff6f3..27d0bc5 100644 --- a/wheretogo/templates/common/base.html +++ b/wheretogo/templates/common/base.html @@ -7,23 +7,16 @@ {% block head_title %}{% endblock %} - + - - - - {% csrf_token %} {% block extra_head %} {% endblock %} + {% csrf_token %}