-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathimagecompare1213.html
131 lines (119 loc) · 3.68 KB
/
imagecompare1213.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
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
131
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Aerial Image Comparison 2012-2013</title>
<script src="src/jquery/jquery-1.7.1.min.js"></script>
<link type="text/css" rel="stylesheet" href="src/leaflet/leaflet.css" />
<script type="text/javascript" src="src/leaflet/leaflet.js"></script>
<script src="src/leaflet/gcc_geosearch/gcc_geosearch.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<link rel="stylesheet" href="src/leaflet/gcc_geosearch/l.gcc_geosearch.css" />
<style>
body { margin:0; padding:0; }
#map {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
height: (100% - 20);
}
#swipe {
background:#fff;
position:absolute;
bottom:0;
left:0;
right:0;
z-index:1000;
padding:10px;
height:30px;
}
#swipe #handle {
position:absolute;
height:20px;
padding:5px;
background:#aaa;
font-weight:bold;
border:1px solid #333;
cursor:pointer;
-webkit-user-select: none;
}
</style>
</head>
<body>
<div id='swipe'>
<div id='handle'>2013 | 2012</div>
</div>
<div id='map'></div>
<script>
var center = new L.LatLng(-42.8337,147.2749);
var map = new L.Map('map', { center: center, zoom: 17, attributionControl:true, zoomControl:false});
///===CHANGE THIS FOR LIVE!===///
var rootURL = "http://tobler-v.glenorchy.tas.gov.au/"
///===========================///
var gccAtt = '© Glenorchy City Council'
var img2012 = new L.TileLayer.WMS(rootURL+"geoserver/gwc/service/wms", {
layers: 'gcc:Glenorchy_Urban_1',
format: 'image/png',
transparent: true,
maxZoom: 20,
attribution: gccAtt
}).addTo(map);
var img2013 = new L.TileLayer.WMS(rootURL+"geoserver/gwc/service/wms", {
layers: 'gcc:Image_2013',
format: 'image/png',
transparent: true,
maxZoom: 20,
attribution: gccAtt
}).addTo(map);
//Search control
L.control.searchControl().addTo(map);
var l_parent = getLayer(map._layers)._container,
handle = document.getElementById('handle'),
dragging = false;
handle.onmousedown = function() { dragging = true; return false;}
document.onmouseup = function() { dragging = false; }
document.onmousemove = function(e) {
if (!dragging) return;
setDivide(e.x);
}
var offset = 45;
map.on( "zoomend", function( e ) {
l_parent = getLayer(map._layers)._container;
setDivide(parseInt(handle.style.left)+offset);
});
map.on( "moveend", function( e ) {
l_parent = getLayer(map._layers)._container;
setDivide(parseInt(handle.style.left)+offset);
});
map.on( "drag", function( e ) {
l_parent = getLayer(map._layers)._container;
setDivide(parseInt(handle.style.left)+offset);
});
map.on( "mousemove", function( e ) {
l_parent = getLayer(map._layers)._container;
setDivide(e.containerPoint.x);
});
function setDivide(x) {
x = Math.max(offset, Math.min(x, (map.getSize()['x'] - offset)));
handle.style.left = (x-offset) + 'px';
var layerX = map.containerPointToLayerPoint(x,0).x
l_parent.style.clip = 'rect(-99999px ' + layerX + 'px 999999px -99999px)';
}
window.onresize = function(event) {
setDivide(map.getSize()['x'] / 2);
}
function getLayer(obj) {
var last;
for (var i in obj) {
if (obj.hasOwnProperty(i) && typeof(i) !== 'function' && obj[i].options.format) {
last = obj[i];
}
}
return last;
}
setDivide(300);
</script>
</body>
</html