feat: add some query params to change behavior
This commit is contained in:
parent
811328dda7
commit
9d471f92a3
1 changed files with 16 additions and 10 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import lignes from './lignes';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
const bbox = lignes.bbox || [0, 0, 0, 0];
|
||||
const centerLat = (bbox[1] + bbox[3]) / 2;
|
||||
|
@ -14,23 +15,28 @@
|
|||
|
||||
const map = L.map('map').setView([centerLat, centerLon], 13);
|
||||
|
||||
L.tileLayer(`https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png`, {
|
||||
const params = $page.url.searchParams;
|
||||
const mapSuffix = params.has('labels') ? 'all' : 'nolabels';
|
||||
|
||||
L.tileLayer(`https://basemaps.cartocdn.com/light_${mapSuffix}/{z}/{x}/{y}{r}.png`, {
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
maxZoom: 20
|
||||
}).addTo(map);
|
||||
|
||||
lignes.features.forEach((feature) => {
|
||||
const options: GeoJSONOptions = {};
|
||||
if (params.has('lines')) {
|
||||
lignes.features.forEach((feature) => {
|
||||
const options: GeoJSONOptions = {};
|
||||
|
||||
if (feature.properties && feature.properties.couleur) {
|
||||
options.style = {
|
||||
color: 'rgb(' + feature.properties.couleur.replaceAll(' ', ',') + ')'
|
||||
};
|
||||
}
|
||||
if (feature.properties && feature.properties.couleur) {
|
||||
options.style = {
|
||||
color: 'rgb(' + feature.properties.couleur.replaceAll(' ', ',') + ')'
|
||||
};
|
||||
}
|
||||
|
||||
L.geoJSON(feature, options).addTo(map);
|
||||
});
|
||||
L.geoJSON(feature, options).addTo(map);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue