mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-12-08 21:26:14 +00:00
42 lines
1.4 KiB
Markdown
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 = '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <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>
|