forked from openseadragon/svg-overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
82 lines (71 loc) · 2.65 KB
/
demo.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html>
<head>
<title>OpenSeadragon SVG Overlay Demo</title>
<script src="https://cdn.jsdelivr.net/npm/openseadragon/build/openseadragon/openseadragon.min.js"></script>
<script src="openseadragon-svg-overlay.js"></script>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//d3js.org/d3.v5.min.js"></script>
<style type="text/css">
html,
body,
.openseadragon1 {
width: 100%;
height: 100%;
margin: 0;
}
</style>
<script>
// ----------
App = {
// ----------
init: function() {
var self = this;
var tileSource = {
Image: {
xmlns: "http://schemas.microsoft.com/deepzoom/2008",
Url: "http://openseadragon.github.io/example-images/highsmith/highsmith_files/",
Format: "jpg",
Overlap: "2",
TileSize: "256",
Size: {
Height: "9221",
Width: "7026"
}
}
};
this.viewer = OpenSeadragon({
id: "contentDiv",
prefixUrl: "https://cdn.jsdelivr.net/npm/openseadragon/build/openseadragon/images/",
tileSources: [{
tileSource: tileSource,
width: 2,
y: 0.5,
x: 0.5
}]
});
var overlay = this.viewer.svgOverlay();
var d3Rect = d3.select(overlay.node()).append("rect")
.style('fill', '#f00')
.attr("x", 0.5)
.attr("width", 0.25)
.attr("y", 0.5)
.attr("height", 0.25);
overlay.onClick(d3Rect.node(), function() {
console.log('click', arguments);
});
$(window).resize(function() {
overlay.resize();
});
}
};
// ----------
$(document).ready(function() {
App.init();
});
</script>
</head>
<body>
<div id="contentDiv" class="openseadragon1"></div>
</body>
</html>