/
githubmirror
/
Leaflet
Обзор
Документация
Войти
/
githubmirror
/
Leaflet
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
debug/map/zoom-levels.html
54 строки
2 KB
Simon Legner
Control: stop exposing modules on other classes (#10054)
07 янв 2026, 18:01
Не верифицирован
07 янв 2026, 18:01
35e4ac2
Код
Авторство
О чём код?
<!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 {LeafletMap, LatLng, TileLayer, LayersControl, ScaleControl, Marker} from 'leaflet'; // Test that changing between layers with differing zoomlevels also updates // the zoomlevels in the map + also const map = new LeafletMap('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 LayersControl({ 'OSM (5-18)': osm2, 'OSM (0-10)': osm }).addTo(map); new ScaleControl().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>