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.5 KiB
HTML
55 lines
1.5 KiB
HTML
<!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, Map, 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 Map('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>
|