Published
Edited
Sep 30, 2022
1 fork
Insert cell
Insert cell
map = {
const container = html`<div style="height:600px;">`;
yield container;

// Create map and attach it to container
const map = L.map(container, {
// Use LV95 (EPSG:2056) projection
crs: L.CRS.EPSG2056
});

// Add Swiss layer with default options
L.tileLayer.swiss().addTo(map);

// Center the map on Switzerland
map.fitSwitzerland();
}
Insert cell
L = {
await require.alias({
// leaflet is a peer dependency of leaflet-tilelayer-swiss
// See https://talk.observablehq.com/t/set-version-of-peer-dependencies/1816
leaflet: "leaflet@1.9.1/dist/leaflet.js"
})("leaflet-tilelayer-swiss@2.3.0");
const L = window.L;

if (!L._style) {
const href = await require.resolve("leaflet@1.9.1/dist/leaflet.css");
document.head.appendChild(
(L._style = html`<link href=${href} rel=stylesheet>`)
);
}
return L;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more