/
githubmirror
/
Leaflet
Обзор
Документация
Войти
/
githubmirror
/
Leaflet
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
debug/map/control-layers.html
61 строка
2 KB
Jon Koops
Drop UMD and make ESM the default entrypoint (#8826)
17 мар 2025, 17:59
Не верифицирован
17 мар 2025, 17:59
7ac9875
Код
Авторство
О чём код?
<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Leaflet debug page - Control Layers</title> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" /> <link rel="stylesheet" href="../../dist/leaflet.css" /> <link rel="stylesheet" href="../css/screen.css" /> <script type="importmap"> { "imports": { "leaflet": "../../dist/leaflet-src.js" } } </script> </head> <body> <div id="map"></div> <style> .grayscale-tile { filter: grayscale(1); } </style> <script type="module"> import {Map, TileLayer, Control, Circle, Polygon, GeoJSON} from 'leaflet'; const GrayscaleTileLayer = TileLayer.extend({ createTile(...args) { const element = TileLayer.prototype.createTile.call(this, ...args); element.classList.add('grayscale-tile'); return element; } }); const map = new Map('map').setView([50.5, 0], 5); const tileUrl = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'; const regularTiles = new TileLayer(tileUrl).addTo(map); const blackAndWhiteTiles = new GrayscaleTileLayer(tileUrl); new Control.Layers({ 'OSM': regularTiles, 'OSM BW': blackAndWhiteTiles }, { 'Circle': new Circle([53, 4], 111111).addTo(map), 'Polygon': new Polygon([[48, -3], [50, -4], [52, 4]]), 'GeoJSON': new GeoJSON({ type: 'Polygon', coordinates: [[ [5.4931640625, 51.781435604431195], [0.9008789062499999, 53.35710874569601], [-2.30712890625, 51.795027225829145], [2.8125, 49.109837790524416], [5.4931640625, 51.781435604431195] ]] }), }, { collapsed: false }).addTo(map); </script> </body> </html>