This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
executable file
·266 lines (208 loc) · 12.2 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<meta id="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<style>
#map {
height: 500px;
width: 100%;
}
* {
color: #000000;
font-size: 20px;
font-weight: 400;
box-sizing: border-box;
font-family: 'Monteserat', Arial, sans-serif;
}
header {
width: 75%;
margin: 25px 25px 25px 25px;
display: inline-block;
position: relative;
height: 60px;
}
nav {
width: calc(25% - 75px);
margin: 25px 25px 25px 0px;
float: right;
}
aside {
width: 25%;
float: left;
min-height: 517px;
}
section {
float: left;
width: calc(75% - 75px);
margin: 0 25px 25px 25px;
}
footer {
width: 96.5%;
margin: 25px 25px 0px 25px;
clear: both;
}
</style>
</head>
<body>
<main>
<header>
<div class="wrapper">
<div class="search-input">
<a href="" target="_blank" hidden></a>
<input type="text" id="myInput" placeholder="Type to search..">
<div class="autocom-box">
<!-- here list are inserted from javascript -->
</div>
<div class="icon"><i ></i></div>
</div>
</div>
<script src="js/suggestions.js"></script>
<script src="js/script.js"></script>
<button type="button" id="search" class = "left_el">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16">
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/>
</svg>
</button>
<button type="button" id="onFeet" style = "position:relative; left:20px;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-walking" viewBox="0 0 16 16">
<path d="M9.5 1.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0ZM6.44 3.752A.75.75 0 0 1 7 3.5h1.445c.742 0 1.32.643 1.243 1.38l-.43 4.083a1.75 1.75 0 0 1-.088.395l-.318.906.213.242a.75.75 0 0 1 .114.175l2 4.25a.75.75 0 1 1-1.357.638l-1.956-4.154-1.68-1.921A.75.75 0 0 1 6 8.96l.138-2.613-.435.489-.464 2.786a.75.75 0 1 1-1.48-.246l.5-3a.75.75 0 0 1 .18-.375l2-2.25Z"/>
<path d="M6.25 11.745v-1.418l1.204 1.375.261.524a.75.75 0 0 1-.12.231l-2.5 3.25a.75.75 0 1 1-1.19-.914l2.345-3.048Zm4.22-4.215-.494-.494.205-1.843a1.93 1.93 0 0 0 .006-.067l1.124 1.124h1.44a.75.75 0 0 1 0 1.5H11a.75.75 0 0 1-.531-.22Z"/>
</svg>
</button>
<button type="button" id="onBycicle" style = "position:relative; left:20px;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bicycle" viewBox="0 0 16 16">
<path d="M4 4.5a.5.5 0 0 1 .5-.5H6a.5.5 0 0 1 0 1v.5h4.14l.386-1.158A.5.5 0 0 1 11 4h1a.5.5 0 0 1 0 1h-.64l-.311.935.807 1.29a3 3 0 1 1-.848.53l-.508-.812-2.076 3.322A.5.5 0 0 1 8 10.5H5.959a3 3 0 1 1-1.815-3.274L5 5.856V5h-.5a.5.5 0 0 1-.5-.5zm1.5 2.443-.508.814c.5.444.85 1.054.967 1.743h1.139L5.5 6.943zM8 9.057 9.598 6.5H6.402L8 9.057zM4.937 9.5a1.997 1.997 0 0 0-.487-.877l-.548.877h1.035zM3.603 8.092A2 2 0 1 0 4.937 10.5H3a.5.5 0 0 1-.424-.765l1.027-1.643zm7.947.53a2 2 0 1 0 .848-.53l1.026 1.643a.5.5 0 1 1-.848.53L11.55 8.623z"/>
</svg>
</button>
<button type="button" id="byCar" style = "position:relative; left:20px;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-car-front-fill" viewBox="0 0 16 16">
<path d="M2.52 3.515A2.5 2.5 0 0 1 4.82 2h6.362c1 0 1.904.596 2.298 1.515l.792 1.848c.075.175.21.319.38.404.5.25.855.715.965 1.262l.335 1.679c.033.161.049.325.049.49v.413c0 .814-.39 1.543-1 1.997V13.5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-1.338c-1.292.048-2.745.088-4 .088s-2.708-.04-4-.088V13.5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-1.892c-.61-.454-1-1.183-1-1.997v-.413a2.5 2.5 0 0 1 .049-.49l.335-1.68c.11-.546.465-1.012.964-1.261a.807.807 0 0 0 .381-.404l.792-1.848ZM3 10a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm10 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM6 8a1 1 0 0 0 0 2h4a1 1 0 1 0 0-2H6ZM2.906 5.189a.51.51 0 0 0 .497.731c.91-.073 3.35-.17 4.597-.17 1.247 0 3.688.097 4.597.17a.51.51 0 0 0 .497-.731l-.956-1.913A.5.5 0 0 0 11.691 3H4.309a.5.5 0 0 0-.447.276L2.906 5.19Z"/>
</svg>
</button>
<button type="button" id="byBus" style = "position:relative; left:20px;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bus-front-fill" viewBox="0 0 16 16">
<path d="M16 7a1 1 0 0 1-1 1v3.5c0 .818-.393 1.544-1 2v2a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5V14H5v1.5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-2a2.496 2.496 0 0 1-1-2V8a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1V2.64C1 1.452 1.845.408 3.064.268A43.608 43.608 0 0 1 8 0c2.1 0 3.792.136 4.936.268C14.155.408 15 1.452 15 2.64V4a1 1 0 0 1 1 1v2ZM3.552 3.22A43.306 43.306 0 0 1 8 3c1.837 0 3.353.107 4.448.22a.5.5 0 0 0 .104-.994A44.304 44.304 0 0 0 8 2c-1.876 0-3.426.109-4.552.226a.5.5 0 1 0 .104.994ZM8 4c-1.876 0-3.426.109-4.552.226A.5.5 0 0 0 3 4.723v3.554a.5.5 0 0 0 .448.497C4.574 8.891 6.124 9 8 9c1.876 0 3.426-.109 4.552-.226A.5.5 0 0 0 13 8.277V4.723a.5.5 0 0 0-.448-.497A44.304 44.304 0 0 0 8 4Zm-3 7a1 1 0 1 0-2 0 1 1 0 0 0 2 0Zm8 0a1 1 0 1 0-2 0 1 1 0 0 0 2 0Zm-7 0a1 1 0 0 0 1 1h2a1 1 0 1 0 0-2H7a1 1 0 0 0-1 1Z"/>
</svg>
</button>
<button type="button" id="byHelicopter" style = "position:relative; left:20px;">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-helicopter" width="16" height="16" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M3 10l1 2h6"></path>
<path d="M12 9a2 2 0 0 0 -2 2v3c0 1.1 .9 2 2 2h7a2 2 0 0 0 2 -2c0 -3.31 -3.13 -5 -7 -5h-2z"></path>
<path d="M13 9l0 -3"></path>
<path d="M5 6l15 0"></path>
<path d="M15 9.1v3.9h5.5"></path>
<path d="M15 19l0 -3"></path>
<path d="M19 19l-8 0"></path>
</svg>
</button>
</header>
<nav>
<img src="src/Coop.jpg" height="80" width="210">
</nav>
<section>
<div id="map"></div>
<script>
var map = L.map('map').setView([46.8,8.13], 8);
const getRouteData = (searchTerm,data) => {
$.getJSON(
"https://basel.do.oliverwisler.ch/backend/routeing",
{location:searchTerm,routingprofile:data},
function(data){
console.log(data);
markerLayer.clearLayers();
data.forEach((element) => {
const lat = parseFloat(element.Latitude);
const lon = parseFloat(element.Longitude);
L.marker([lat,lon]).addTo(markerLayer);
})
const myLat = parseFloat(data[0].coordinates[0][1]);
const myLon = parseFloat(data[0].coordinates[0][0]);
var coopIcon = L.icon({
iconUrl: 'src/myLocationIcon.jpg',
iconSize: [30, 35],
});
map.flyTo([myLat, myLon], 12.2);
L.marker([myLat, myLon], {icon: coopIcon}).addTo(markerLayer);
L.geoJSON(data[0].features).addTo(markerLayer);
});
}
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var cor={};
const markerLayer = L.layerGroup().addTo(map);
$(document).ready(function(){
$("#search").click(function(){
const searchTerm = $("#myInput").val().trim();
$.getJSON(
"https://hack.do.oliverwisler.ch/backend/calculations",
{location:searchTerm},
function(data){
console.log(data);
markerLayer.clearLayers();
$("#coops").empty();
data.forEach((element) => {
const lat = parseFloat(element.Latitude);
const lon = parseFloat(element.Longitude);
L.marker([lat,lon]).addTo(markerLayer);
const tableBlock = $("#coops").append(`<tr>\
<td>${element.Name}</td>\
<td> ${parseFloat(element.Distance)/1000}km</td>\
</tr>\
<tr>\
<td>${element.StreetName} ${element.HouseNumber}, ${element.CityName}</td>\
<td> </td>\
</tr> \
<tr>\
<td><hr></td>\
<td><hr></td>\
</tr>`);
})
const myLat = parseFloat(data[0].coordinates[1]);
const myLon = parseFloat(data[0].coordinates[0]);
var coopIcon = L.icon({
iconUrl: 'src/myLocationIcon.jpg',
iconSize: [30, 35],
});
map.flyTo([myLat, myLon], 12.2);
L.marker([myLat, myLon], {icon: coopIcon}).addTo(markerLayer);
//L.geoJSON(data[0].features).addTo(markerLayer);
});
});
$("#onFeet").click(function(){
const searchTerm = $("#myInput").val().trim();
getRouteData(searchTerm,"foot-walking")
});
$("#onBycicle").click(function(){
const searchTerm = $("#myInput").val().trim();
getRouteData(searchTerm,"cycling-regular")
});
$("#byCar").click(function(){
const searchTerm = $("#myInput").val().trim();
getRouteData(searchTerm,"driving-car")
});
$("#byHelicopter").click(function(){
const searchTerm = $("#myInput").val().trim();
getRouteData(searchTerm,"foot-walking")
});
});
</script>
</section>
<aside>
<table id="coops">
</table>
</aside>
</main>
</body>
</html>