Ajout de l'eau potable
This commit is contained in:
parent
270449766f
commit
251cfa9a8a
2 changed files with 42 additions and 19 deletions
46
js/map.js
46
js/map.js
|
|
@ -14,13 +14,27 @@ export async function init(){
|
|||
|
||||
map = L.map(document.getElementById("map"), {
|
||||
attributionControl: false,
|
||||
zoomControl: false
|
||||
zoomControl: false,
|
||||
zoomSnap: 1,
|
||||
zoomDelta: 1
|
||||
})
|
||||
|
||||
map.addEventListener("zoom", () => {
|
||||
map.getContainer()
|
||||
.style.setProperty("--zoom-level", map.getZoom())
|
||||
})
|
||||
{
|
||||
let zoom_interval = null
|
||||
function updateCssZoom(){
|
||||
map.getContainer()
|
||||
.style.setProperty("--zoom-level", map.getZoom())
|
||||
}
|
||||
map.addEventListener("zoom", updateCssZoom)
|
||||
map.addEventListener("zoomstart", () => {
|
||||
zoom_interval = setInterval(updateCssZoom, 50)
|
||||
updateCssZoom()
|
||||
})
|
||||
map.addEventListener("zoomend", () => {
|
||||
zoom_interval = clearInterval(zoom_interval)
|
||||
updateCssZoom()
|
||||
})
|
||||
}
|
||||
|
||||
L.control.attribution({
|
||||
position: 'topright'
|
||||
|
|
@ -85,11 +99,20 @@ export async function init_places(places_db){
|
|||
}).addTo(map)
|
||||
|
||||
// La couche des zones disponibles
|
||||
const bathrooms = L.geoJSON(null, {
|
||||
const amenities = L.geoJSON(null, {
|
||||
pointToLayer: function(feature, latlng) {
|
||||
let iconEl = document.createElement("div")
|
||||
iconEl.classList.add("map-amenity-icon-container")
|
||||
|
||||
if(feature.properties["eau potable"]){
|
||||
let drinking_water_icon = document.createElement("img")
|
||||
drinking_water_icon.src = new URL("../icons/eau-potable.svg", import.meta.url).toString()
|
||||
drinking_water_icon.alt = "Icone d'une goute"
|
||||
drinking_water_icon.title = "Eau potable"
|
||||
drinking_water_icon.classList.add("drinking-water")
|
||||
iconEl.append(drinking_water_icon)
|
||||
}
|
||||
|
||||
if(feature.properties["toilettes"]){
|
||||
let bathrooms_icon = document.createElement("img")
|
||||
bathrooms_icon.src = new URL("../icons/toilettes.svg", import.meta.url).toString()
|
||||
|
|
@ -108,15 +131,6 @@ export async function init_places(places_db){
|
|||
iconEl.append(shower_icon)
|
||||
}
|
||||
|
||||
if(feature.properties["eau potable"]){
|
||||
let drinking_water_icon = document.createElement("img")
|
||||
drinking_water_icon.src = new URL("../icons/eau-potable.svg", import.meta.url).toString()
|
||||
drinking_water_icon.alt = "Icone d'une goute"
|
||||
drinking_water_icon.title = "Eau potable"
|
||||
drinking_water_icon.classList.add("drinking-water")
|
||||
iconEl.append(drinking_water_icon)
|
||||
}
|
||||
|
||||
let icon = L.divIcon({
|
||||
className: "map-amenity-icon",
|
||||
html: iconEl
|
||||
|
|
@ -143,7 +157,7 @@ export async function init_places(places_db){
|
|||
amenity_feature = feature
|
||||
}
|
||||
|
||||
bathrooms.addData(amenity_feature)
|
||||
amenities.addData(amenity_feature)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue