/
githubmirror
/
Leaflet
Обзор
Документация
Войти
/
githubmirror
/
Leaflet
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
debug/vector/moving-canvas.html
54 строки
1 KB
Simon Legner
Rename `Map` to `LeafletMap` and keep `Map` as alias (#9892)
11 ноя 2025, 21:28
Не верифицирован
11 ноя 2025, 21:28
2e9b617
Код
Авторство
О чём код?
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>Leaflet debug page - Moving Canvas</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 {TileLayer, LeafletMap, CircleMarker} from 'leaflet'; const osm = new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' }); const map = new LeafletMap('map', {preferCanvas: true}) .setView([50.5, 30.51], 15) .addLayer(osm); const markers = []; const colors = ['red', 'green', 'blue', 'purple', 'cyan', 'yellow']; for (let i = 0; i < 20; i++) { markers.push(new CircleMarker([50.5, 30.51], {color: colors[i % colors.length]}).addTo(map)); } function update() { const t = new Date().getTime() / 1000; markers.forEach((marker, i) => { const v = t * (1 + i / 10) + (12.5 * i) / 180 * Math.PI; marker.setLatLng([ 50.5 + (i % 2 ? 1 : -1) * Math.sin(v) * 0.005, 30.51 + (i % 3 ? 1 : -1) * Math.cos(v) * 0.005, ]); }); requestAnimationFrame(update); } update(); </script> </body> </html>