-
Notifications
You must be signed in to change notification settings - Fork 0
/
deltademslider.html
198 lines (163 loc) · 7.73 KB
/
deltademslider.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>CWS Experiments: Historical Delta Slider</title>
<head>
<!-- Setup Before-After Plugin dependencies -->
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.10.3.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="js/jquery.beforeafter-map-0.11.js"></script>
<!-- Setup Leaflet -->
<script type="text/javascript" src="js/leaflet.js"></script>
<link rel="stylesheet" type="text/css" href="css/leaflet.css"/>
<!-- ESRI-leaflet plugin-->
<script type="text/javascript" src="js/esri-leaflet.js"></script>
<!-- Font awesome icons -->
<link rel="stylesheet" href="css/font-awesome-4.3.0/css/font-awesome.min.css">
</head>
<body>
<img src="https://watershed.ucdavis.edu/files/cwsheader_0.png">
<h1>Historical vs Modern Delta</h1>
<h2>Elevation Model Slider Map</h2>
<p>The <a href="https://watershed.ucdavis.edu">UC Davis Center for Watershed Sciences</a> created an interactive slider map to showcase the work on the historical elevation model of the Sacramento - San Joaquin River Delta. This interactive map compares the historical elevation model (circa the mid-1800s) with the present day digital elevation model for the Delta. For more information about this project, please see <a href = "https://watershed.ucdavis.edu/project/historical-delta-elevation-model"> Historical Delta Elevation Model</a>.</p>
<p>The historical elevation model was built in collaboration with the <a href = "http://www2.sfei.org/"> San Francisco Estuary Institute</a> and <a href="http://www.rmanet.com/"> Resource Management Associates</a>. The model was constructed using historical data from early river surveys to characterize the hydrodynamics of the Delta prior to human modifications.The modern digital elevation model is from the <a href="http://baydeltaoffice.water.ca.gov/modeling/deltamodeling/modelingdata/DEM.cfm">DWR Bay-Delta 10m DEM</a>.
<p><b>Use the handle in the middle to switch between the historical elevation model (on the left) and the modern elevation model (on the right). The background basemap can be switched using the dialog box. The transparency of the DEM layers can be adjusted using the input slider in the lower left. Click the expand button to view in full screen. For best viewing, please use Chrome or Firefox.</b></p>
<style>
body {
padding: 0;
margin-left: 75px;
margin-right: 75px;
}
#basemaps-wrapper {
position: absolute;
top: 15px;
left: 75px;
z-index: 10;
background: white;
padding: 10px;
}
#basemaps {
margin-bottom: 5px;
}
#map-container{
margin-left:auto;
margin-right:auto;
border:1px solid black;
}
#slide{
-webkit-appearance: none;
position: absolute;
width: 200px;
bottom: 10px;
left: 10px;
z-index: 10;
border-radius: 15px;
background: white;
height: 7px;
border: 1px solid black;
}
#legend {
margin-left:auto;
margin-right: auto;
text-align: center;
padding:10px;
}
#fullicon {
position: absolute;
top: 15px;
right: 15px;
z-index: 10;
}
</style>
<!-- Create a map container div and divs for your two maps -->
<div id="map-container">
<!-- Make sure to give the map divs height and width -->
<div id="before" style="height:600px;width:900px;"></div>
<div id="after" style="height:600px;width:900px;"></div>
<div id="basemaps-wrapper" class="leaflet-bar">
<select name="basemaps" id="basemaps">
<option value="Oceans">Oceans<options>
<option value="Topographic">Topographic<options>
<option value="Streets">Streets</option>
<option value="NationalGeographic">National Geographic<options>
<option value="Gray">Gray<options>
<option value="DarkGray">Dark Gray<options>
<option value="Imagery">Imagery<options>
<option value="ShadedRelief">Shaded Relief<options>
</select>
</div>
<div id="fullicon">
<a href="slider-fullscreen.html"><i class="fa fa-expand fa-3x" style="color:grey"></i></a>
</div>
<div>
<input id="slide" type="range" min="0" max="1" step="0.05" value="0.75" onchange="updateOpacity(this.value)">
</div>
</div>
<div id="legend">
<img src="legend.png" style="width:600px;border:1px solid black;">
</div>
<p></p>
<p>Built using Leaflet, JQuery, and ESRI basemaps by <a href="https://watershed.ucdavis.edu/people/Andy-Bell">Andy Bell</a>. <a href="https://watershed.ucdavis.edu/project/historical-delta-elevation-model">More project information</a>. </p>
<script type="text/javascript">
$(function() {
// create a map in the "before" and "after" divs, set the view to a given place and zoom
// You may want to turn attributionControl off so that the Leaflet attribution doesn't slide with the slider. Place all attribution on the after map.
// You may also want to turn off inertia, which in some cases can cause the maps to go out of sync
// inital map state
var center = [38.2,-121.8];
var zoom = 9;
var start_opacity = 0.75
// create before and after maps
before = L.map('before', {attributionControl: false, inertia: false, minZoom: 8}).setView(center, zoom);
after = L.map('after', {attributionControl: false, inertia: false, minZoom: 8}).setView(center, zoom);
// before layer
var before_layer = new L.esri.Layers.DynamicMapLayer("http://atlas.cws.ucdavis.edu/arcgis/rest/services/HistoricalDelta/HistoricalDelta_v6r4/MapServer", {opacity:start_opacity}).addTo(before);
// after layer;
var after_layer = new L.esri.Layers.DynamicMapLayer("http://atlas.cws.ucdavis.edu/arcgis/rest/services/HistoricalDelta/Modern_Delta/MapServer", {opacity:start_opacity}).addTo(after);
// initial state of the basemaps for both maps (default is oceans)
var base_before = L.esri.basemapLayer('Oceans').addTo(before);
var base_after = L.esri.basemapLayer('Oceans').addTo(after);
// Base map selector function to change basemap styles
var layerLabels; // layer for basemap layers
//for each map change the layer to a new ESRI basemap style
function setBasemap(map, layer, basemap) {
// remove current style
if (layer) {
map.removeLayer(layer);
}
// change layer to desired basemap style
layer = L.esri.basemapLayer(basemap);
// adds new style to map
map.addLayer(layer);
// removes layer labels
if (layerLabels) {
map.removeLayer(layerLabels);
}
// basemap options with labels
if (basemap === 'ShadedRelief' || basemap === 'Oceans' || basemap === 'Gray' || basemap === 'DarkGray' || basemap === 'Imagery' || basemap === 'Terrain') {
layerLabels = L.esri.basemapLayer(basemap + 'Labels');
map.addLayer(layerLabels);
}};
// event listener to change basemaps
var basemaps = document.getElementById('basemaps');
basemaps.addEventListener('change', function(){
setBasemap(after, base_after, basemaps.value);
setBasemap(before, base_before, basemaps.value);
});
// opacity controls
function updateOpacity(value) {
before_layer.setOpacity(value);
after_layer.setOpacity(value);
}
// event listener to change opacity
var slide = document.getElementById('slide');
slide.addEventListener('change', function(){
updateOpacity(slide.value);
$("#legend").css("opacity", slide.value); // changes opacity of legend
});
// Call the Before-After plugin
$('#map-container').beforeAfter(before,after, {showFullLinks: false});});
</script>
</body>
</html>