-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
94 lines (85 loc) · 2.85 KB
/
index.html
File metadata and controls
94 lines (85 loc) · 2.85 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Prueba LeafletJS</title>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.2/dist/leaflet.css"
integrity="sha256-sA+zWATbFveLLNqWO2gtiw3HL/lh1giY/Inf1BJ0z14="
crossorigin=""
/>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi"
crossorigin="anonymous"
/>
</head>
<body>
<h1>Registro Nacional de Barrios Populares</h1>
<button onclick="screenshot()">Click me</button>
<section id="map" style="width: 100%; height: 600px"></section>
<canvas id="canvas"></canvas>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3"
crossorigin="anonymous"
></script>
<script
src="https://unpkg.com/leaflet@1.9.2/dist/leaflet.js"
integrity="sha256-o9N1jGDZrf5tS+Ft4gbIK7mYMipq9lqpVJ91xHSyKhg="
crossorigin=""
></script>
<script src="html2canvas.min.js"></script>
<script>
const map = L.map('map', {
scrollWheelZoom: true,
preferCanvas: true
}).setView([51.508, -0.11], 15)
var tiles = L.tileLayer(
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
{
maxZoom: 19,
attribution:
'<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
}
).addTo(map);
var circle = L.circle([51.508, -0.11], {
color: "red",
fillColor: "#f03",
fillOpacity: 0.5,
radius: 500,
}).addTo(map);
</script>
<script type="text/javascript">
function screenshot() {
html2canvas(document.getElementById("map"), {
allowTaint: false,
logging: true,
taintTest: false,
useCORS: true,
width: document.getElementById("map").offsetWidth,
height: document.getElementById("map").offsetHeight,
}).then(function (canvas) {
const image = canvas.toDataURL("image/png");
var link = document.createElement("a");
if (link.download !== undefined) {
let d = new Date();
let n = d.getTime();
link.download = "mapaIGN" + n;
link.href = image;
document.body.appendChild(link);
//window.jQuery(link).css("display", "none");
link.click();
document.body.removeChild(link);
} else {
console.log("error");
}
});
}
</script>
</body>
</html>