-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
258 lines (203 loc) · 8.3 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
<!doctype html>
<html lang="en">
<!-- Der Head -->
<head>
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css"
type="text/css" />
<link rel="stylesheet" href="bulma.css" type="text/css" />
<link rel="stylesheet" href="own.css" type="text/css" />
<link rel="shortcut icon" href="favicon.png" />
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<title>Potat0 Maps</title>
</head>
<body>
<div id="locations"></div>
<!-- Die Buttons/Der Button -->
<div id="header">
<div id="description">
<div class="divider"></div>
</div>
<form>
<input type=text id="search" class="input">
<img src="./loading.gif" height="30" width="30" id="loadingcircle" />
</form>
<div id="buttons"></div>
</div>
<!-- Die Karte -->
<div id="map">
</div>
<!-- Laden der POI's-->
<script type="text/javascript">
var arrpoi = [];
var locations = [];
//Einlesen der JSON-File: https://ethercalc.net/80v6flbti30d.csv.json
$.ajax({
url: 'https://ethercalc.net/80v6flbti30d.csv.json',
dataType: 'json',
type: 'get',
cache: 'false',
success: function (data) {
$(data).each(function (index, value) {
arrpoi[index] = value;
arrcoor = arrpoi[index][2].split(", ");
var coor = [];
var coor1 = parseFloat(arrcoor[0]);
var coor2 = parseFloat(arrcoor[1]);
coor.push(coor2, coor1);
var poi = {
name: arrpoi[index][0],
id: arrpoi[index][1],
coordinates: coor,
description: arrpoi[index][3],
tags: arrpoi[index][4],
address: arrpoi[index][5]
}
locations["poi" + index] = poi;
})
console.log("Loaded POI's successful!");
loadmap();
}
})
</script>
<!-- Anfang vom Javascript -->
<script type="text/javascript">
function loadmap() {
$("#loadingcircle").fadeOut(1000);
var poi0 = { coordinates: [14.245475, 51.438972] };
var iconStyle = new ol.style.Style({
image: new ol.style.Icon({
anchor: [0.5, 640],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
src: 'test.png',
scale: 0.1
})
});
function createClickListener(locObj) {
return function () {
$('.box1').fadeOut("fast")
var point = ol.proj.fromLonLat(locObj.coordinates);
var size = map.getSize();
view1.setCenter(ol.proj.fromLonLat(locObj.coordinates))
view1.setZoom(17)
console.log(locObj.id);
document.getElementById(locObj.name).style.display = "block"
}
}
var buttonsDiv = document.getElementById('buttons');
var guiDiv = document.getElementById('locations')
// pins
var iconFeatureList = [];
var textFeatureList = [];
for (var locIndex in locations) {
var locObj = locations[locIndex];
var buttonelement = document.createElement('button');
buttonelement.setAttribute('id', locObj.id);
buttonelement.setAttribute("class", "button")
buttonelement.innerHTML = locObj.name;
var divider = document.createElement('div');
divider.setAttribute('class', 'divider')
buttonsDiv.appendChild(divider)
buttonsDiv.appendChild(buttonelement);
var guielement = document.createElement('div');
guielement.setAttribute('id', locObj.name);
guielement.setAttribute("class", "box1")
var innerGUI = locObj.name + "<br /> <br />" + locObj.description + "<br /> Adresse: " + locObj.address
guielement.innerHTML = innerGUI
guiDiv.appendChild(guielement);
/* Damit etwas passiert, wenn man auf den Button klickt */
buttonelement.addEventListener('click', createClickListener(locObj))
var textStyle = new ol.style.Style({
text: new ol.style.Text({
text: locObj.name,
offsetY: 8,
scale: 1.5
})
});
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat(locObj.coordinates)),
});
iconFeature.setStyle(iconStyle);
iconFeatureList.push(iconFeature);
var textFeature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat(locObj.coordinates)),
});
textFeature.setStyle(textStyle);
textFeatureList.push(textFeature);
}
/* Die verschiedenen Layer */
var vectorSource = new ol.source.Vector({
features: iconFeatureList
});
var vectorSource2 = new ol.source.Vector({
features: textFeatureList
});
var vectorLayer1 = new ol.layer.Vector({
source: vectorSource,
minResolution: 0,
maxResolution: 30
});
var vectorLayer2 = new ol.layer.Vector({
source: vectorSource2,
minResolution: 7,
maxResolution: 12
});
/* Für die Karte benötigtes Zeug */
var properties = {
center: ol.proj.fromLonLat(poi0.coordinates),
zoom: 17,
minZoom: 2,
maxZoom: 19
}
var view1 = new ol.View(properties)
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}), vectorLayer2, vectorLayer1
],
controls: [
new ol.control.Zoom({
className: 'custom-zoom'
})
],
view: view1
});
var inputDiv = document.getElementById('search');
document.addEventListener('keyup', function (event) {
search(inputDiv.value);
});
var search = function (searchString) {
searchString = searchString.toLowerCase().trim();
var results = [];
var ids = [];
for (var locIndex in locations) {
var locObj = locations[locIndex];
document.getElementById(locObj.id).style.display = "none"
var name = locObj.name.toLowerCase(), description = locObj.description.toLowerCase(), tags = locObj.tags.toLowerCase();
if (name.indexOf(searchString) >= 0) {
results.push(locObj.name);
ids.push(locObj.id);
}
else if (description.indexOf(searchString) >= 0) {
results.push(locObj.name);
ids.push(locObj.id);
}
else if (tags.indexOf(searchString) >= 0) {
results.push(locObj.name);
ids.push(locObj.id);
}
}
console.log(results);
console.log(ids);
for (var idIndex in ids) {
var id = ids[idIndex]
document.getElementById(id).style.display = "inline-block";
}
}
}
</script>
</body>
</html>