-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsuttapitaka2.html
More file actions
130 lines (102 loc) · 3.19 KB
/
suttapitaka2.html
File metadata and controls
130 lines (102 loc) · 3.19 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
129
130
<!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>
<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>
<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-sidebar.js' | absolute_url }}"></script> -->
<script>
let map = L.map("image-map", {
crs: L.CRS.Simple,
minZoom: 1,
maxZoom: 4,
});
function loadImage(url) {
return new Promise((resolve, reject) => {
const img = new Image();
img.addEventListener("load", () => resolve(img));
img.addEventListener("error", reject);
img.src = url;
});
}
async function getImageData(url) {
const img = await loadImage(url);
return {
img,
width: img.naturalWidth,
height: img.naturalHeight
};
}
async function showOnMap(url) {
const {
img,
width,
height
} = await getImageData(url);
const southWest = map.unproject([0, height], map.getMaxZoom());
const northEast = map.unproject([width, 0], map.getMaxZoom());
const bounds = new L.LatLngBounds(southWest, northEast);
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);
// $('[.leaflet-bar][.easy-button-container][.leaflet-control]').insertAfter('[.leaflet-top][.leaflet-right]')
// ctlSidebar = L.control.sidebar('side-bar').addTo(map);
// ctlEasybutton = L.easyButton('<span style="font-size: 1.5em;">×</span>',
// function () {
// history.back()
// }).setPosition('bottomright').addTo(map);
}
showOnMap(
"assets/img/suttapitaka-min2.png"
);
</script>
</body>