forked from vporwal/maps-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basemapcomparer.html
125 lines (112 loc) · 3.56 KB
/
basemapcomparer.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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>LIST Basemap Comparer</title>
<script src="src/jquery/jquery-1.7.1.min.js"></script>
<link type="text/css" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/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'>NEW | OLD</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: 10, attributionControl:true, zoomControl:false});
var LISTTopographic = new L.tileLayer("https://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/Topographic/ImageServer/tile/{z}/{y}/{x}", {
attribution: "Basemap © The LIST",
maxZoom: 18,
maxNativeZoom: 18
}).addTo(map);
var LISTBeta = new L.tileLayer("https://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/TopographicBeta/ImageServer/tile/{z}/{y}/{x}", {
attribution: "Basemap © The LIST",
maxZoom: 20,
maxNativeZoom: 19
}).addTo(map);
var gccAtt = '© Glenorchy City Council'
//Search control
L.control.searchControl().addTo(map);
var l_parent = LISTBeta._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 = LISTBeta._container;
setDivide(parseInt(handle.style.left)+offset);
});
map.on( "moveend", function( e ) {
l_parent = LISTBeta._container;
setDivide(parseInt(handle.style.left)+offset);
});
map.on( "drag", function( e ) {
l_parent = LISTBeta._container;
setDivide(parseInt(handle.style.left)+offset);
});
map.on( "mousemove", function( e ) {
l_parent = LISTBeta._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