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>
55 lines
1.6 KiB
HTML
55 lines
1.6 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Leaflet debug page - Zoom Levels</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>
|
|
<script type="module">
|
|
import {Map, LatLng, TileLayer, Control, Marker} from 'leaflet';
|
|
|
|
// Test that changing between layers with differing zoomlevels also updates
|
|
// the zoomlevels in the map + also
|
|
|
|
const map = new Map('map').setView(new LatLng(50.5, 30.51), 0);
|
|
const osmAttrib = '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
|
|
const osm = new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: osmAttrib, minZoom: 0, maxZoom: 10}).addTo(map);
|
|
const osm2 = new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: 'Hello world', minZoom: 5, maxZoom: 18});
|
|
|
|
new Control.Layers({
|
|
'OSM (5-18)': osm2,
|
|
'OSM (0-10)': osm
|
|
}).addTo(map);
|
|
|
|
new Control.Scale().addTo(map);
|
|
|
|
function getRandomLatLng(llbounds) {
|
|
const s = llbounds.getSouth();
|
|
const n = llbounds.getNorth();
|
|
const w = llbounds.getWest();
|
|
const e = llbounds.getEast();
|
|
|
|
return new LatLng(
|
|
s + (Math.random() * (n - s)),
|
|
w + (Math.random() * (e - w))
|
|
);
|
|
}
|
|
|
|
for (let i = 0; i < 1000; i++) {
|
|
new Marker(getRandomLatLng(map.getBounds())).addTo(map);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|