-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
210 lines (186 loc) · 6.17 KB
/
index.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
199
200
201
202
203
204
205
206
207
208
209
210
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
crossorigin=""
/>
<script
src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA=="
crossorigin=""
></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-polylinedecorator/1.1.0/leaflet.polylineDecorator.min.js"></script>
<script src="https://unpkg.com/topojson-client@3"></script>
<script src="https://unpkg.com/leaflet.vectorgrid@latest/dist/Leaflet.VectorGrid.bundled.js"></script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.3/awesomplete.min.css"
integrity="sha256-dOShescFo9s9hVGH7lA2HL6Tdq/GUO77T9/cihQMc/E="
crossorigin="anonymous"
/>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.3/awesomplete.min.js"
integrity="sha256-5pJRRi3xV/K9xpez4N3jlLTH2Jy0ErXkMML4sjnj6Xc="
crossorigin="anonymous"
></script>
<script src="js/osmtogeojson.js"></script>
<script src="wikiosm_data.js"></script>
<script src="wikiosm_leaflet.js"></script>
<script src="data.js"></script>
<style>
body {
padding: 0;
margin: 0;
}
html,
body,
#map {
height: 100%;
width: 100%;
}
.overlay {
height: 100%;
width: 100%;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
background-color: rgb(0 0 0);
background-color: rgba(0 0 0 0.9);
overflow-x: hidden;
}
/* Position the content inside the overlay */
.overlay-content {
position: relative;
top: 25%; /* 25% from the top */
width: 100%; /* 100% width */
text-align: center; /* Centered text/links */
margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
}
.overlay .closebtn {
position: absolute;
top: 20px;
right: 45px;
font-size: 60px;
}
.overlay a,
.overlay div {
text-decoration: none;
font-size: 36px;
color: #818181;
}
@media screen and (max-height: 450px) {
.overlay a,
. overlay div {
font-size: 20px;
}
.overlay .closebtn {
font-size: 40px;
top: 15px;
right: 35px;
}
}
</style>
</head>
<body>
<div id="map"></div>
<div id="loading" class="overlay">
<!-- Button to close the overlay navigation -->
<a
href="javascript:void(0)"
class="closebtn"
onclick="showLoading('none')"
>×</a
>
<!-- Overlay content -->
<div class="overlay-content">
<div>OSM30minHydro</div>
<div>Loading data</div>
</div>
</div>
<script>
var map = L.map("map").fitWorld();
var mapLayers = new Layers(map);
mapLayers.basin_min_strahler = 1;
mapLayers.selected_basin_id = -1;
fetch_ddm30_lines(mapLayers);
// create the tile layer with correct attribution
// https://switch2osm.org/using-tiles/getting-started-with-leaflet/
var osmUrl = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
openCurrentView = e => {
window.open(
`https://www.openstreetmap.org/#map=${map.getZoom()}/${
map.getCenter().lat
}/${map.getCenter().lng}`,
"_blank"
);
e.preventDefault();
};
var osmAttrib =
'Map data © <a href="https://openstreetmap.org" onClick="openCurrentView(event);">OpenStreetMap</a> contributors';
var osm = L.tileLayer(osmUrl, {
minZoom: 0,
maxZoom: 12,
attribution: osmAttrib
}).addTo(map);
function isBasinKnown(basin_name) {
return basin_wiki.some(x => x[1] && x[1].startsWith(basin_name));
}
function select_basin(basin_id) {
if (
typeof basin_id == "string" &&
isNaN(basin_id) &&
!isBasinKnown(basin_id)
) {
showLoading("block");
load_tributaries_wiki(basin_id).then(layer => {
layer.addTo(map, "Tributaries");
showLoading("none");
map.fitBounds(layer.getBounds());
});
}
if (
typeof basin_id == "undefined" ||
isNaN(basin_id) ||
basin_id === ""
)
return null;
mapLayers.remove("Selected basin");
// TODO: allow points to accumulate instead?
mapLayers.removeFromControl("Wikidata river coordinates");
mapLayers.selected_basin_id = basin_id;
var basin_layer = Object.values(mapLayers.Basins_orig._layers).filter(
x => x.feature.properties.basin_id == basin_id
)[0];
if (typeof basin_layer === "undefined") return null;
var basin_bounds = basin_layer.getBounds();
load_wikidata_river_coords(basin_bounds).then(layer =>
mapLayers.addToControl(layer, "Wikidata river coordinates")
);
var wiki = basin_wiki.filter(x => x[0] == basin_id).map(x => x[1]);
if (!(wiki === null || !wiki[0] || /^\s*$/.test(wiki[0]))) {
showLoading("block");
load_tributaries_wiki(wiki).then(layer => {
layer.addTo(map, "Tributaries");
showLoading("none");
});
}
load_basin_ddm(mapLayers, basin_id);
updateSelectionLabel(basin_id, wiki);
highlightSelectedBasin(mapLayers, basin_id);
}
load_ddm30_basins(mapLayers, select_basin).then(x => showLoading("none"));
get_basin_wiki()
.then(x => (window.basin_wiki = x))
.then(x => setupSelectionLabel(map));
function showLoading(display) {
document.getElementById("loading").style.display = display;
}
</script>
</body>
</html>