-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsuttapitaka.html
More file actions
128 lines (106 loc) · 2.93 KB
/
suttapitaka.html
File metadata and controls
128 lines (106 loc) · 2.93 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="fr">
<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, maximum-scale=1.0, user-scalable=no" />
<title>Sutta Pitaka</title>
<!-- <meta name="description" content="{{ site.description }}"> -->
<!-- <link rel="apple-touch-icon" href="{{ site.icon }}"> -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.1/dist/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="https://cdn.leafletjs.com/leaflet-0.7.2/leaflet.ie.css" /><![endif]-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet-easybutton@2/src/easy-button.css">
<!-- <link rel="stylesheet" href="{{ '/assets/css/leaflet-sidebar.css' | absolute_url }}"> -->
<!-- <link rel="stylesheet" href="{{ '/assets/css/leaflet.css' | absolute_url }}"> -->
<style>
body {
padding: 0;
margin: 0;
}
html,
body {
height: 100%;
width: 100%;
}
#image-map {
width: 100%;
height: 100%;
/* border: 1px solid #ccc; */
border: 0px solid #ccc;
margin-bottom: 10px;
background-color: rgba(255, 0, 0, 0.0);
outline: 0;
}
.easy-button-container {
/* width: calc(100vw - 25px);
display: flex;
justify-content: flex-end; */
position: absolute;
left: calc(100vw - 60px);
/* border: none !important; */
}
.easy-button-button .button-state {
display: flex;
align-items: center;
justify-content: center;
}
</style>
</head>
<body>
<div id="image-map"></div>
<div id="svg" style="position: absolute; bottom: 0; left: 0; width: 0; height: 0;"></div>
<script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"></script>
<script src="https://cdn.jsdelivr.net/npm/leaflet-easybutton@2/src/easy-button.js"></script>
<!-- <script src="{{ '/assets/js/leaflet.js' | absolute_url }}"></script> -->
<script>
let map = L.map("image-map", {
crs: L.CRS.Simple,
minZoom: -4,
maxZoom: 1,
});
const url =
"assets/img/suttapitaka3.svg";
async function fetchData(url) {
try {
const response = await fetch(url);
const data = await response.text();
return data;
} catch (err) {
console.error(err);
}
}
fetchData(url)
.then((svg) => {
const map = document.getElementById("svg");
map.insertAdjacentHTML("afterbegin", svg);
})
.then(() => {
const svgElement = document.getElementById("svg");
const {
width,
height
} = svgElement.firstChild.getBBox();
return {
width,
height
};
})
.then(({
width,
height
}) => {
const img = new Image();
img.src = url;
const bounds = [
[0, 0], // padding
[width, height], // image dimensions
];
L.imageOverlay(img.src, bounds).addTo(map);
map.fitBounds(bounds);
L.easyButton('<span style="font-size: 1.8em;" id="close">×</span>',
function() {
history.back()
}).addTo(map);
});
</script>
</body>