File: custom-panes.html

package info (click to toggle)
leaflet 1.4.0~dfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 19,000 kB
  • sloc: sh: 26; makefile: 24; xml: 23
file content (69 lines) | stat: -rw-r--r-- 1,733 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
<!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>
	
	<style>
		body { max-width: 1200px }
		#mapSvg { width: 500px; height: 500px; margin: 20px }
		#mapCanvas { width: 500px; height: 500px; margin: 20px }
		.left { float: left; text-align: center }
		.right { float: right; text-align: center }
	</style>
</head>
<body>

	<div class="right">
		<h1>Canvas</h1>
		<div id="mapCanvas"></div>
	</div>
	<div class="left">
		<h1>SVG</h1>
		<div id="mapSvg"></div>
	</div>

	<script>

		function makeMap(container, options) {
			var osmUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
				osmAttrib = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
				osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib});

			var map = L.map(container, options)
				.setView([50.5, 30.51], 15)
				.addLayer(osm);

				map.createPane('custom1');
				map.createPane('custom2');
				map.getPane('custom1').style.zIndex = 601;
				map.getPane('custom2').style.zIndex = 701;

				var panes = ['overlayPane', 'custom1', 'custom2'];

			function makeFeatures(i) {
				L.marker([50.505-i*0.005, 30.51]).addTo(map);
				L.circleMarker([50.505-i*0.005, 30.51], { radius: 30, pane: panes[i] })
					.bindPopup(function(layer) {
						return 'Pane: ' + panes[i];
					})
					.addTo(map);
			}

			for (var i = 0; i < 3; i++)
				makeFeatures(i);
		}

		makeMap('mapSvg');
		makeMap('mapCanvas', { preferCanvas: true });

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