-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
65 lines (49 loc) · 1.81 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
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Map Print Plugin Demo</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
<style>
html {background: #222222;}
</style>
</head>
<body class="mapPrint">
<div id="map" style="height:400px; width:900px"></div>
<button onclick="manualPrint()">Print Map</button>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<script src="dist/bundle.js"></script>
<script>
const map = L.map('map').setView([51.4999, -0.0748], 13);
const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://openstreetmap.org">OpenStreetMap</a> contributors',
}).addTo(map);
L.marker([51.4999, -0.0748]).addTo(map)
.bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup();
L.circle([51.4912, -0.0980], 500, {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.6
}).addTo(map).bindPopup("I am a circle.");
L.polygon([
[51.5081, -0.0667],
[51.5086, -0.0480],
[51.4966, -0.0479],
[51.4966, -0.0648]
]).addTo(map).bindPopup("I am a polygon.");
const popup = L.popup();
const printer = L.mapPrint({
tileLayer: tiles,
sizeModes: ['Current', 'A4Landscape', 'A4Portrait'],
filename: 'myMap',
exportOnly: true,
hideControlContainer: true
}).addTo(map);
function manualPrint() {
printer.printMap('CurrentSize', 'customPrintImage')
}
</script>
</body>
</html>