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>
58 lines
1.4 KiB
HTML
58 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Leaflet debug page - Popup Context Menu Clicks</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>
|
|
<button id="populate">Populate with 10 markers</button>
|
|
<script type="module">
|
|
import {Map, TileLayer, GeoJSON, Marker} from 'leaflet';
|
|
|
|
const map = new Map('map').setView([36.9, -95.4], 5);
|
|
|
|
map.on('contextmenu', () => {
|
|
alert('The map has been right-clicked');
|
|
});
|
|
|
|
new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
|
|
|
|
const exampleGeoJSON = {
|
|
type: 'Polygon',
|
|
coordinates: [
|
|
[
|
|
[-90.0, 35.0],
|
|
[-90.0, 45.0],
|
|
[-100.0, 45.0],
|
|
[-100.0, 35.0],
|
|
],
|
|
],
|
|
};
|
|
|
|
new GeoJSON(exampleGeoJSON, {
|
|
onEachFeature(feature, layer) {
|
|
layer.on('contextmenu', () => {
|
|
alert('The GeoJSON layer has been clicked');
|
|
});
|
|
},
|
|
}).addTo(map);
|
|
|
|
const marker = new Marker([36, -95]).addTo(map);
|
|
marker
|
|
.bindPopup('Right-click me <br> to test contextmenu <br> event capture')
|
|
.openPopup();
|
|
</script>
|
|
</body>
|
|
</html>
|