/
githubmirror
/
Leaflet
Обзор
Документация
Войти
/
githubmirror
/
Leaflet
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
debug/map/svg-overlay.html
44 строки
1 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 - SVG Overlay</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" style='width:750px; height: 450px;'></div> <svg id="image" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><rect width="200" height="200"/><rect x="75" y="23" width="50" height="50" style="fill:red"/><rect x="75" y="123" width="50" height="50" style="fill:#0013ff"/></svg> <script type="module"> import {Map, TileLayer, LatLngBounds, SVGOverlay} from 'leaflet'; const map = new Map('map'); new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {maxZoom: 19}).addTo(map); const svgElement = document.querySelector('#image'); const bounds = new LatLngBounds([[32, -130], [13, -100]]); map.fitBounds(bounds); const overlay = new SVGOverlay(svgElement, bounds, { opacity: 0.7, interactive: true }); map.addLayer(overlay); const element = overlay.getElement(); element.addEventListener('click', () => console.log('click!')); </script> </body> </html>