-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathindex.html
60 lines (57 loc) · 1.89 KB
/
index.html
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
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Leaflet.Control.FullScreen Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@latest/dist/leaflet.css" />
<link rel="stylesheet" href="Control.FullScreen.css" />
<link rel="icon" type="image/svg+xml" href="icon-fullscreen.svg" />
<style type="text/css">
#map {
width: 700px;
max-width: 100%;
height: 433px;
}
</style>
<script src="https://unpkg.com/leaflet@latest/dist/leaflet.js"></script>
<script src="Control.FullScreen.js"></script>
</head>
<body>
<div id="map"></div>
<div style="margin: 1em 0 0">
<span style="padding: 0 0.25em 0 0">Demonstration of 'toggleFullscreen' method</span>
<button type="button" onclick="toggleFullscreen();">Show map in fullscreen mode</button>
</div>
<script>
const base = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
maxZoom: 19,
subdomains: 'abcd',
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>'
});
let map = L.map('map', {
layers: [base],
tap: false, // ref https://github.com/Leaflet/Leaflet/issues/7255
center: new L.LatLng(48.5, -4.5),
zoom: 5,
fullscreenControl: true,
fullscreenControlOptions: {
// optional
title: 'Show me the fullscreen!',
titleCancel: 'Exit fullscreen mode'
}
});
// detect fullscreen toggling
map.on('enterFullscreen', function () {
if (window.console) window.console.log('enterFullscreen');
});
map.on('exitFullscreen', function () {
if (window.console) window.console.log('exitFullscreen');
});
// toggler into fullscreen mode
const toggleFullscreen = function () {
map.toggleFullscreen();
};
</script>
</body>
</html>