chcederquist 9b89ab4eb5
Updated title and descriptions of docs (#9692)
Co-authored-by: Florian Bischof <design.falke@gmail.com>
2025-05-09 18:47:17 +02:00

42 lines
1.4 KiB
Markdown

---
layout: tutorial_frame
title: Custom Pane Example
---
<script type="text/javascript" src="eu-countries.js"></script>
<script type="module">
import L, {Map, TileLayer, GeoJSON} from 'leaflet';
const map = new Map('map');
map.createPane('labels');
// This pane is above markers but below popups
map.getPane('labels').style.zIndex = 650;
// Layers in this pane are non-interactive and do not obscure mouse/touch events
map.getPane('labels').style.pointerEvents = 'none';
const cartodbAttribution = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/attribution">CARTO</a>';
const positron = new TileLayer('https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png', {
attribution: cartodbAttribution
}).addTo(map);
const positronLabels = new TileLayer('http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png', {
attribution: cartodbAttribution,
pane: 'labels'
}).addTo(map);
/* global euCountries */
const geojson = new GeoJSON(euCountries).addTo(map);
geojson.eachLayer((layer) => {
layer.bindPopup(layer.feature.properties.name);
});
map.setView({lat: 47.040182144806664, lng: 9.667968750000002}, 4);
globalThis.L = L; // only for debugging in the developer console
globalThis.map = map; // only for debugging in the developer console
</script>