Ajout de l'eau potable
This commit is contained in:
parent
270449766f
commit
251cfa9a8a
2 changed files with 42 additions and 19 deletions
|
|
@ -77,17 +77,26 @@ body, html {
|
||||||
.map-amenity-icon .map-amenity-icon-container {
|
.map-amenity-icon .map-amenity-icon-container {
|
||||||
transform: translateX(-50%) translateY(-50%);
|
transform: translateX(-50%) translateY(-50%);
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
display: flex;
|
display: grid;
|
||||||
flex-direction: row;
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
grid-template-rows: repeat(2, min-content);
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
|
|
||||||
|
& > img {
|
||||||
|
width: 2rem;
|
||||||
|
transform: scale( clamp(0.5, calc( var(--zoom-level) - 19 ), 1) );
|
||||||
|
transform-origin: 50% 50%;
|
||||||
|
}
|
||||||
|
|
||||||
& > * {
|
& > * {
|
||||||
opacity: clamp(0, calc( var(--zoom-level) - 19 ), 1) ;
|
opacity: clamp(0, calc( var(--zoom-level) - 19 ), 1) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
& > .drinking-water {
|
& > .drinking-water {
|
||||||
opacity: clamp(0, calc( var(--zoom-level) - 20 ), 1) ;
|
grid-row: 1;
|
||||||
|
grid-column: 1;
|
||||||
|
opacity: clamp(0, calc( var(--zoom-level) - 18 ), 1) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
40
js/map.js
40
js/map.js
|
|
@ -14,13 +14,27 @@ export async function init(){
|
||||||
|
|
||||||
map = L.map(document.getElementById("map"), {
|
map = L.map(document.getElementById("map"), {
|
||||||
attributionControl: false,
|
attributionControl: false,
|
||||||
zoomControl: false
|
zoomControl: false,
|
||||||
|
zoomSnap: 1,
|
||||||
|
zoomDelta: 1
|
||||||
})
|
})
|
||||||
|
|
||||||
map.addEventListener("zoom", () => {
|
{
|
||||||
|
let zoom_interval = null
|
||||||
|
function updateCssZoom(){
|
||||||
map.getContainer()
|
map.getContainer()
|
||||||
.style.setProperty("--zoom-level", map.getZoom())
|
.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({
|
L.control.attribution({
|
||||||
position: 'topright'
|
position: 'topright'
|
||||||
|
|
@ -85,11 +99,20 @@ export async function init_places(places_db){
|
||||||
}).addTo(map)
|
}).addTo(map)
|
||||||
|
|
||||||
// La couche des zones disponibles
|
// La couche des zones disponibles
|
||||||
const bathrooms = L.geoJSON(null, {
|
const amenities = L.geoJSON(null, {
|
||||||
pointToLayer: function(feature, latlng) {
|
pointToLayer: function(feature, latlng) {
|
||||||
let iconEl = document.createElement("div")
|
let iconEl = document.createElement("div")
|
||||||
iconEl.classList.add("map-amenity-icon-container")
|
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"]){
|
if(feature.properties["toilettes"]){
|
||||||
let bathrooms_icon = document.createElement("img")
|
let bathrooms_icon = document.createElement("img")
|
||||||
bathrooms_icon.src = new URL("../icons/toilettes.svg", import.meta.url).toString()
|
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)
|
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({
|
let icon = L.divIcon({
|
||||||
className: "map-amenity-icon",
|
className: "map-amenity-icon",
|
||||||
html: iconEl
|
html: iconEl
|
||||||
|
|
@ -143,7 +157,7 @@ export async function init_places(places_db){
|
||||||
amenity_feature = feature
|
amenity_feature = feature
|
||||||
}
|
}
|
||||||
|
|
||||||
bathrooms.addData(amenity_feature)
|
amenities.addData(amenity_feature)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue