Реструкторизованы статические файлы

This commit is contained in:
2022-04-21 18:21:48 +03:00
parent 291286bbb1
commit bc5782cac8
13 changed files with 42 additions and 38 deletions

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 486 B

After

Width:  |  Height:  |  Size: 486 B

View File

Before

Width:  |  Height:  |  Size: 973 B

After

Width:  |  Height:  |  Size: 973 B

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,24 @@
const copy = "© <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> 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);