File: zoom-delta.html

package info (click to toggle)
leaflet 1.7.1~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 16,972 kB
  • sloc: javascript: 16,627; makefile: 49; sh: 26; xml: 23
file content (108 lines) | stat: -rw-r--r-- 2,617 bytes parent folder | download | duplicates (3)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
<head>
	<title>Leaflet debug page</title>

	<meta name="viewport" content="initial-scale=1.0" />

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

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

	<script src="../leaflet-include.js"></script>
	<style>
	.container {
		float:left; width: 600px; height: 600px;
		position: relative;
		border: 1px solid gray;
	}
	#map1, #map2 {
		position:absolute;
		top:2em;
		bottom:2em;
		left:0;
		right:0;
	}
	#zoom1, #zoom2 {
		position:absolute;
		bottom:0;
		left:0;
		right:0;
	}
	</style>
</head>
<body>

	<h1>Zoom delta test.</h1>

	<p>Zooming with touch zoom, box zoom or flyTo then <code>map.stop()</code> must make the zoom level snap to the value of the <code>zoomSnap</code> option. Zoom interactions (keyboard, mouse wheel, zoom control buttons must change the zoom by the amount in the <code>zoomDelta</code> option.</p>

	<div>
		<button id="sf">SF</button>
		<button id="trd">TRD</button>
		<button id="stop">stop</button>
	</div>

	<div class='container'>
		Snap: 0.25. Delta: 0.5.
		<div id="map1"></div>
		<span id="zoom1"></span>
	</div>
	<div class='container'>
		Snap: 0 (off). Delta: 0.25.
		<div id="map2"></div>
		<span id="zoom2"></span>
	</div>

	<script>

		var sf = [37.77, -122.42],
			trd = [63.41, 10.41];

		var osmUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
			osmAttrib = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
			osm1 = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
			osm2 = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
			center = L.latLng(63.41, 10.41);

		var map1 = new L.Map('map1', {
			center: center,
			layers: [osm1],
			zoom: 5,
			zoomSnap: 0.25,
			zoomDelta: 0.5,
			wheelPxPerZoomLevel: 50
		});

		var map2 = new L.Map('map2', {
			center: center,
			layers: [osm2],
			zoom: 5,
			zoomSnap: 0,
			zoomDelta: 0.25,
			wheelPxPerZoomLevel: 50
		});

		map1.on('zoomend',function(){
			document.getElementById('zoom1').innerHTML = "Zoom level: " + map1.getZoom();
		});
		map2.on('zoomend',function(){
			document.getElementById('zoom2').innerHTML = "Zoom level: " + map2.getZoom();
		});

		document.getElementById('sf').onclick   = function () {
			map1.flyTo(sf, 10, {duration: 20});
			map2.flyTo(sf, 10, {duration: 20});
		};
		document.getElementById('trd').onclick  = function () {
			map1.flyTo(trd, 10, {duration: 20});
			map2.flyTo(trd, 10, {duration: 20});
		};
		document.getElementById('stop').onclick = function () {
			map1.stop();
			map2.stop();
		};

	</script>
</body>
</html>