File: moving-canvas.html

package info (click to toggle)
leaflet 1.7.1~dfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 16,996 kB
  • sloc: javascript: 16,627; makefile: 48; xml: 23; sh: 21
file content (50 lines) | stat: -rw-r--r-- 1,500 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
	<title>Leaflet debug page</title>

	<link rel="stylesheet" href="../../dist/leaflet.css" />

	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<link rel="stylesheet" href="../css/screen.css" />

	<script src="../leaflet-include.js"></script>
</head>
<body>

	<div id="map"></div>

	<script>

		var osmUrl = 'https://api.mapbox.com/styles/v1/mapbox/light-v9/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw',
			osmAttrib = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
			osm = L.tileLayer(osmUrl, {maxZoom: 18, tileSize: 512, zoomOffset: -1, attribution: osmAttrib});

		var map = L.map('map', {preferCanvas: true})
				.setView([50.5, 30.51], 15)
				.addLayer(osm);

		var markers = [];
		var colors = ['red', 'green', 'blue', 'purple', 'cyan', 'yellow'];
		for (var i = 0; i < 20; i++) {
			markers.push(L.circleMarker([50.5, 30.51], {color: colors[i % colors.length]}).addTo(map));
		}

		function update() {
			var t = new Date().getTime() / 1000;
			markers.forEach(function(marker, i) {
				var 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,
					]);
			});

			L.Util.requestAnimFrame(update);
		}

		update();
	</script>
</body>
</html>