forked from go-iiif/go-iiif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
77 lines (57 loc) · 1.56 KB
/
index.js
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
window.addEventListener('load', function(e){
var qs = window.location.search;
qs = qs.substring(1);
var params = {};
var queries = qs.split("&");
var count = queries.length;
for ( var i = 0; i < count; i++ ) {
temp = queries[i].split('=');
params[temp[0]] = temp[1];
}
var id = '184512_5f7f47e5b3c66207_x.jpg'; // disk
if (params['id']){
id = params['id'];
}
var map = L.map('map', {
center: [0, 0],
crs: L.CRS.Simple,
zoom: 1,
minZoom: 1,
});
var i = document.getElementById("image");
i.onclick = function(){
leafletImage(map, function(err, canvas) {
if (err){
console.log(err);
alert("Argh! There was a problem capturing your image");
return false;
}
var dt = new Date();
var iso = dt.toISOString();
var iso = iso.split('T');
var ymd = iso[0];
ymd = ymd.replace("-", "", "g");
var bounds = map.getPixelBounds();
var zoom = map.getZoom();
var pos = [
bounds.min.x,
bounds.min.y,
bounds.max.x,
bounds.max.y,
zoom
];
pos = pos.join("-");
var name = id + "-" + ymd + "-" + pos + ".png";
canvas.toBlob(function(blob) {
saveAs(blob, name);
});
// window.open(body);
});
};
var info = 'http://' + location.host + '/' + id + '/info.json';
var opts = {
'quality': 'default',
'tileFormat': 'jpg',
};
map.addLayer(L.tileLayer.iiif(info, opts));
});