From bc5782cac80cc586116d0b7b95d11e22cd2e7cc9 Mon Sep 17 00:00:00 2001 From: Llloooggg Date: Thu, 21 Apr 2022 18:21:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D1=8B=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wheretogo/static/{ => common}/img/about.txt | 0 .../img/android-chrome-192x192.png | Bin .../img/android-chrome-512x512.png | Bin .../{ => common}/img/apple-touch-icon.png | Bin .../static/{ => common}/img/favicon-16x16.png | Bin .../static/{ => common}/img/favicon-32x32.png | Bin wheretogo/static/{ => common}/img/favicon.ico | Bin .../static/{ => common}/img/site.webmanifest | 0 wheretogo/static/{ => maps}/css/map.css | 0 wheretogo/static/maps/js/map.js | 24 ++++++++++ wheretogo/templates/common/base.html | 11 +---- wheretogo/templates/maps/map.html | 43 ++++++------------ wheretogo/wheretogo/settings_var.py_template | 2 +- 13 files changed, 42 insertions(+), 38 deletions(-) rename wheretogo/static/{ => common}/img/about.txt (100%) rename wheretogo/static/{ => common}/img/android-chrome-192x192.png (100%) rename wheretogo/static/{ => common}/img/android-chrome-512x512.png (100%) rename wheretogo/static/{ => common}/img/apple-touch-icon.png (100%) rename wheretogo/static/{ => common}/img/favicon-16x16.png (100%) rename wheretogo/static/{ => common}/img/favicon-32x32.png (100%) rename wheretogo/static/{ => common}/img/favicon.ico (100%) rename wheretogo/static/{ => common}/img/site.webmanifest (100%) rename wheretogo/static/{ => maps}/css/map.css (100%) create mode 100644 wheretogo/static/maps/js/map.js 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 %}