mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-12-08 21:26:14 +00:00
Signed-off-by: Jon Koops <jonkoops@gmail.com> Co-authored-by: Florian Bischof <design.falke@gmail.com>
45 lines
1.4 KiB
HTML
45 lines
1.4 KiB
HTML
<!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>
|