-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrimet_trip_game.html
778 lines (650 loc) · 21.8 KB
/
trimet_trip_game.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title>Trimet Trip Game</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
crossorigin=""/>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
crossorigin=""></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/leaflet.textpath.min.js"></script>
<style>
/* beginning style for itinerary bubbles */
.circle {
height: 15px;
width: 15px;
background-color: #555;
border-radius: 50%;
margin: 5px;
}
.circle:hover {
background-color:rgb(183, 170, 170);
}
.circle:active {
background-color:rgb(183, 170, 170);
}
.circle:hover .tooltiptext {
visibility: visible;
}
.circle:active .tooltiptext {
visibility: visible;
}
.circle .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
/* Position the tooltip */
position: relative;
z-index: 15;
top:22px;
display: block;
}
.flex-container {
display: flex;
background-color: rgb(211, 216, 221);
/* margin-right:10px; */
border-radius:10px;
}
.mega-flex {
display: flex;
column-gap: 1em;
max-width: 620px;
}
/* end style for itinerary bubbles */
.bad_circle {
display: flex;
height: 25px;
width: 25px;
background-color: rgb(211, 120, 120);
color: #444;
border-radius: 50%;
margin: 5px;
justify-content: center;
align-items: center;
}
.bad_circle:hover {
background-color: rgb(205, 143, 143);
}
.bad_circle:active {
background-color: rgb(205, 143, 143);
}
.bad_circle:hover .bad_tooltiptext {
visibility: visible;
width: fit-content;
}
.bad_circle:active .bad_tooltiptext {
visibility: visible;
width: fit-content;
}
.bad_circle .bad_tooltiptext {
visibility: hidden;
width: 120px;
background-color: rgb(222, 143, 143);
color: #000000;
text-align: center;
border-radius: 6px;
padding: 5px 0;
/* Position the tooltip */
position: relative;
z-index: 15;
top:22px;
display: block;
}
#bad_tooltiptext_id.bad_tooltiptext {
position: absolute;
top: 32px;
}
.wrap_all {position: relative;}
.main-grid { grid-area: main;
position: static;
top: 12%;
width: 100%;
z-index: 2;
height: 100%;
display: flex;
}
.header {
display: flex;
width: 100%;
text-align: center;
justify-content: center;
}
@media screen and (max-width: 900px) {
.header {
display: flex;
text-align: center;
justify-content: center;
flex-direction: column;
}
}
@media (max-width:900px) {
#info-explainer {
width: 250px;
}
}
@media (min-width:900px) {
#info-explainer {
width: 333px;
}
}
.h1 {
margin-top: 0px;
margin-bottom: 0px;
font-size: 22px;
text-align:center;
}
#map { height: 80vh; z-index: 8;}
#header_id {
column-gap: 1em;
}
#button_container {
text-align: center;
display: flex;
justify-content: center;
align-content: center;
align-items: center;
column-gap: 1em;
position: relative;
}
.intin_routes {
display: block;
}
/* info button */
.info {
width: 25px;
height: 25px;
z-index: 5;
position: absolute;
top:2%;
right:2%;
}
.modal {
position: absolute;
z-index: 10;
background: rgb(254, 254, 254);
transition: all 0.4s;
text-align: center;
opacity: 1;
padding: 50px;
height: 75%;
width: 50%;
}
.button-close-modal {
position: absolute;
top:2%;
right:2%;
padding: 0;
border: none;
background: none;
font-size: 1.5rem;
font-weight: bold;
}
</style>
</head>
<div id="wrap_all">
<div class="header" id="header_id">
<div class="h1">Trimet Trip Game</div>
<div id="search_drop_down">
<label for="selected_route_dropdown"></label>
<input list="selected_route_dropdown" onfocus="this.value=''" onChange="get_dropdown_data(this.value)" placeholder = "Select a route"/>
<datalist class="legend" id="selected_route_dropdown" name="routes" placeholder="">
</datalist>
</div>
</div>
<img class="info" src="info_icon.svg" alt="Info Button" style="width:30px;height:30px;" onclick="openModal()">
<div class="main-grid">
<dialog class="modal">
<h3 style="color: rgb(0, 0, 0);">
<button class="button-close-modal">X</button>
<h3 style="font-size:24px;">Welcome to the TriMet Trip Planner Game!</h3>
<p style="font-size:18px;">The goal of the game is to select the route(s) to get from the origin point to the destination point.
Use the dropdown to search and select route(s).
</p>
<p style="font-size:18px;">Track your progress with the dots on top:</p>
<br><a href="#info-explainer"><img id="info-explainer" src="website_explainer.svg" alt="explainer" style=></a>
<p style="font-size:18px;font-style: bold;">Extra Details:</p><p>The game refreshes 3 times a day (~8am, ~12pm, ~6pm Pacific). There are up to 3 itineraries with a walking
distance of 1,609 feet to/from transit or the origin/destination. For MAX lines that overlap, select all
options (the game defaults to the "first" route given by the TriMet Trip Planner). Trip itineraries are generated by the TriMet
Trip Planner for travel from the origin to destination at 12:00pm of the current day.
</p><br>
<p>Made by
<a href="https://github.com/sidetrackedmind">@sidetrackedmind</a>
</p>
<p>
<a href="https://forms.gle/mCrCcnqPyBM5tfSL7" style="font-size:18px;font-style: bold;">Feedback Form</a>
</p>
</dialog>
</div>
<body>
<div id="button_container">
<div class="bad_circle" id="bad_circle_id">
</div>
<div class="mega-flex" id="itin_contain">
</div>
</div>
<div id="context_container">
</div>
</div>
<div id="map"></div>
</div>
<body>
<script>
const modal = document.querySelector('.modal');
modal.showModal();
function openModal() {
const modal = document.querySelector('.modal');
console.log("openModal");
modal.showModal();
};
function closeModal() {
const modal = document.querySelector('.modal');
console.log("closeModal");
modal.close();
};
document.addEventListener(
"click",
function (event) {
// If user clicks outside the modal window, then close modal by calling closeModal()
if (
event.target.closest(".button-close-modal")
) {
console.log("clicked on not the modal");
closeModal();
}
},
false
);
var header_id_element = document.getElementById("header_id");
fetch("https://raw.githubusercontent.com/sidetrackedmind/trimet_trip_game/main/trip_planner_query_time.json")
.then(function (response){
return response.json();
})
.then(function (data) {
// console.log(data['query_time'])
var query_time_div = document.createElement("div");
var query_time = data['query_time'];
query_time_div.textContent = "Trip query time: "+query_time
header_id_element.appendChild(query_time_div);
}
);
// add driving duration
var button_container_element = document.getElementById("button_container");
fetch("https://meysohn-sandbox.s3.amazonaws.com/trimet_trip_planner/driving_route.json")
.then(function (response){
return response.json();
})
.then(function (data) {
// console.log(data['duration_typical'])
var driving_duration_div = document.createElement("div");
var totalDrivingSeconds = data['duration_typical'];
let drivinghours = Math.floor(totalDrivingSeconds / 3600);
totalDrivingSeconds %= 3600;
let drivingminutes = Math.floor(totalDrivingSeconds / 60);
let totalDrivingMinutes = (drivinghours*60)+drivingminutes;
driving_duration_div.textContent = "Driving time: "+totalDrivingMinutes+" mins"
button_container_element.appendChild(driving_duration_div);
}
);
// for itineraries
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
// I know this is wrong but I want to get the json object into a reusable variable...
var xhReq = new XMLHttpRequest();
xhReq.open("GET", "https://meysohn-sandbox.s3.amazonaws.com/trimet_trip_planner/itinerary_routes_long_name.geojson", false);
xhReq.send(null);
var itin_routes_long_name = JSON.parse(xhReq.responseText);
var xhReq = new XMLHttpRequest();
xhReq.open("GET", "https://meysohn-sandbox.s3.amazonaws.com/trimet_trip_planner/origin_destination_centriod.geojson", false);
xhReq.send(null);
var centroid_geojson = JSON.parse(xhReq.responseText);
var xhReq = new XMLHttpRequest();
xhReq.open("GET", "https://meysohn-sandbox.s3.amazonaws.com/trimet_trip_planner/itineraries_reduced_with_long_name.geojson", false);
xhReq.send(null);
var itineraries_reduced_geojson = JSON.parse(xhReq.responseText);
// console.log(itineraries_reduced_geojson);
var itinerary_dict = {};
var itinerary_duration_dict = {};
var itinerary_alt_dict = {};
for (var i = 0; i < itineraries_reduced_geojson['features'].length; i++) {
var one_row = itineraries_reduced_geojson['features'][i];
// console.log(one_row);
var itinerary_idx = one_row['properties']['itin_idx'];
var totalSeconds = one_row['properties']['totalTime'];
console.log(itinerary_idx+":"+"totalSeconds: "+ totalSeconds);
let hours = Math.floor(totalSeconds / 3600);
totalSeconds %= 3600;
let minutes = Math.floor(totalSeconds / 60);
let totalMinutes = (hours*60)+minutes;
let seconds = totalSeconds % 60;
// console.log("hours: " + hours);
// console.log("minutes: " + minutes);
// console.log("seconds: " + seconds);
// If you want strings with leading zeroes:
minutes = String(minutes).padStart(2, "0");
hours = String(hours).padStart(2, "0");
seconds = String(seconds).padStart(2, "0");
total_time_formatted = totalMinutes + " mins"
itinerary_duration_dict[itinerary_idx] = total_time_formatted;
var route_idx = one_row['properties']['leg_id'];
if (one_row['properties']['route_id']!='WALK') {
if (!(itinerary_idx in itinerary_dict)) {
var route_dict = {};
route_dict[route_idx] = one_row['properties']['route_id']
itinerary_dict[itinerary_idx] = [one_row['properties']['route_id']]
itinerary_alt_dict[itinerary_idx] = route_dict;
}
else {
route_dict[route_idx] = one_row['properties']['route_id']
itinerary_dict[itinerary_idx].push(one_row['properties']['route_id'])
}
}
else {
// pass 'WALK' routes
}
}
console.log(itinerary_dict);
console.log(itinerary_alt_dict);
console.log(itinerary_duration_dict);
for (const [key, value] of Object.entries(itinerary_alt_dict)) {
var itinerary_container = document.getElementById("itin_contain");
var itin_div = document.createElement("div");
itin_div.setAttribute("class","flex-container");
itin_div.setAttribute("id","itinerary"+key);
itin_div.dataset.total_routes = Object.keys(value).length;
itinerary_container.appendChild(itin_div);
// add routes to itinerary
// var itin_div = document.getElementById("itinerary"+key);
for (const [route_key, route_value] of Object.entries(value)) {
// console.log(route_key);
var route_div_circle = document.createElement("div");
route_div_circle.setAttribute("class","circle");
route_div_circle.setAttribute("id",key+"_"+route_key);
itin_div.appendChild(route_div_circle);
}
};
var good_routes = [];
var route_color_dict = {};
for (var i = 0; i < itin_routes_long_name['features'].length; i++) {
var one_route = itin_routes_long_name['features'][i];
// console.log(one_route);
var good_route_dd_name = one_route['properties'].route_id;
var good_route_color = one_route['properties'].route_color;
route_color_dict[good_route_dd_name] = good_route_color;
good_routes.push(good_route_dd_name);
}
console.log(good_routes);
console.log(route_color_dict);
function processGeoJSONData(data, desired_value) {
// Filter the data based on a property (e.g., 'property_name')
const filteredData = data.features.filter(feature => {
return Number(feature.properties.route_id) === desired_value;
});
// Load the filtered data onto the map
loadGoodDataOnMap(filteredData);
}
function loadGoodDataOnMap(filteredData) {
const geoJsonLayer = L.geoJSON(filteredData, {
onEachFeature: onEachGoodFeature
}).addTo(map);
}
function loadBadDataOnMap(data) {
const geoJsonLayer = L.geoJSON(data, {
onEachFeature: onEachBadFeature
}).addTo(map);
// Set the z-index of the GeoJSON layer
map.getPane('geojsonPane').style.zIndex = 500;
}
function onEachBadFeature(feature, layer) {
layer.setStyle({
color: '#e0aaa4',
weight: 2,
opacity: .65
});
layer.on({
mouseover: highlightBadFeature,
mouseout: resetBadRouteLines
});
}
function onEachGoodFeature(feature, layer) {
const feature_color = feature.properties.route_color;
layer.setStyle({
color: feature_color,
weight: 4,
opacity: .85
});
layer.on({
mouseover: highlightFeature,
mouseout: resetRouteLines
});
}
function highlightFeature(e) {
const layer = e.target;
const feature_color = layer.feature.properties.route_color;
const tooltipText = layer.feature.properties.dropdown_route;
layer.setStyle({
color: "#e0db31", //yellow-ish
weight: 6,
opacity: .85
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
const tooltip = layer.bindTooltip(tooltipText, {
permanent: false,
sticky: true,
direction: 'center',
className: 'custom-tooltip' // Optional: Add a custom CSS class for styling
});
tooltip.openTooltip(e.latlng);
}
function highlightBadFeature(e) {
const layer = e.target;
const tooltipText = layer.feature.properties.route_id + " - " +layer.feature.properties.route_long_name;
layer.setStyle({
color: '#f55e22',
weight: 4,
opacity: .65
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
const tooltip = layer.bindTooltip(tooltipText, {
permanent: false,
sticky: true,
direction: 'center',
className: 'custom-tooltip' // Optional: Add a custom CSS class for styling
});
tooltip.openTooltip(e.latlng);
}
function resetRouteLines(e) {
const layer = e.target;
const feature_color = layer.feature.properties.route_color;
console.log("I'm in resetline");
layer.setStyle({
color: feature_color,
weight: 4,
opacity: .85
});
}
function resetBadRouteLines(e) {
const layer = e.target;
layer.setStyle({
color: '#e0aaa4',
weight: 2,
opacity: .65
});
}
var dd_select = document.getElementById("selected_route_dropdown");
fetch("https://meysohn-sandbox.s3.amazonaws.com/trimet_trip_planner/gtfs_routes.json")
.then(function (response){
return response.json();
})
.then(function (data) {
for(var i = 0; i < data.length; i++) {
var opt = data[i];
var el = document.createElement("option");
el.textContent = opt.route_id + " - " + opt.route_long_name;
el.value = opt.route_id + " - " + opt.route_long_name;
el.id = opt.route_id;
dd_select.appendChild(el);
}
});
var selected_good_routes = [];
var selected_good_route_ids = [];
var selected_bad_routes = [];
function get_dropdown_data(val){
var route_id = Number(val.split(" - ")[0]);
// console.log(val.attr('textContent'));
if (good_routes.includes(route_id)) {
// block of code to be executed if the condition is true
fetch("https://meysohn-sandbox.s3.amazonaws.com/trimet_trip_planner/itineraries_reduced_with_long_name.geojson")
.then(response => response.json())
.then(data => {
// Process the GeoJSON data here
processGeoJSONData(data, route_id);
})
.catch(error => console.error(error));
selected_good_routes.push(val);
//go through the alt itinerary dict and turn the circles blue
for (const [it_key, it_value] of Object.entries(itinerary_alt_dict)) {
for (const [route_key, route_value] of Object.entries(it_value)) {
if (route_value == route_id && !selected_good_route_ids.includes(route_id)) {
//color correct circle same color as route
circle_color = route_color_dict[route_id]
correct_circle = document.getElementById(it_key+"_"+route_key);
correct_circle.setAttribute("style", "background-color:"+circle_color+";");
//add route name to ciricle
if ((correct_circle.children.length<1)) {
var route_tooltip = document.createElement("span");
route_tooltip.setAttribute("class","tooltiptext");
route_tooltip.textContent = val;
correct_circle.appendChild(route_tooltip);
}
else {}
itin_div = document.getElementById("itinerary"+it_key);
//add to the running total of correct routes in the itinerary
if (!("running_total" in itin_div.dataset)) {
itin_div.dataset.running_total = 1;
itin_div.dataset.route_list = route_id;
}
else if (!(itin_div.dataset.route_list.split(", ").includes(route_id))) {
itin_div.dataset.running_total = Number(itin_div.dataset.running_total) + 1;
itin_div.dataset.route_list += ', ' + route_id;
}
else {}
//check if circle is last route in the itinerary
if (itin_div.dataset.total_routes == itin_div.dataset.running_total && itin_div.dataset.running_total == itin_div.children.length) {
console.log("turn blue!")
itin_div.setAttribute("style", "background-color:#83adf5;align-items:center;width:fit-content;padding-right:5px");
var win_tooltip = document.createElement("span");
win_tooltip.setAttribute("class","tooltiptext");
total_itinerary_duration = itinerary_duration_dict[it_key];
win_tooltip.textContent = "You WIN! "+"Trip time: "+ total_itinerary_duration;
itin_div.appendChild(win_tooltip);
}
else {}
<<<<<<< HEAD
selected_good_route_ids.push(route_id);
=======
>>>>>>> 815477635c1b3d7800425f42653029e85265125f
}
else {}
}
}
selected_good_route_ids.push(route_id);
}
else {
// block of code to be executed if the condition is false
//https://meysohn-sandbox.s3.amazonaws.com/trimet_trip_planner/route_lines/route_line_2.geojson
route_url = "https://meysohn-sandbox.s3.amazonaws.com/trimet_trip_planner/route_lines/route_line_" + route_id + ".geojson"
fetch(route_url)
.then(response => response.json())
.then(data => {
// Load the GeoJSON data here
loadBadDataOnMap(data);
})
.catch(error => console.error(error));
selected_bad_routes.push(val)
var num_bad_guesses = selected_bad_routes.length;
console.log("number of bad guesses");
console.log(num_bad_guesses);
var bad_guesses_circle = document.getElementById("bad_circle_id");
bad_guesses_circle.textContent = num_bad_guesses;
var element = document.getElementById('elementId');
if (typeof(element) != 'undefined' && element != null)
{
console.log('span exists - getting it')
var span_item = document.getElementById("bad_tooltiptext_id");
}
else {
console.log('span does not exist - creating it')
var span_item = document.createElement("span");
span_item.setAttribute("class","bad_tooltiptext");
span_item.setAttribute("id","bad_tooltiptext_id");
bad_guesses_circle.appendChild(span_item);
}
for(var i = 0; i < selected_bad_routes.length; i++) {
var para_item = document.createElement("p");
para_item.textContent = selected_bad_routes[i];
para_item.setAttribute("style", "margin:2px;");
span_item.appendChild(para_item);
}
}
}
var map = L.map('map').setView([centroid_geojson['features'][0]['geometry']['coordinates'][1], centroid_geojson['features'][0]['geometry']['coordinates'][0]], 12);
L.tileLayer('https://tiles.stadiamaps.com/tiles/stamen_toner_lite/{z}/{x}/{y}{r}.png?api_key=7049c2c0-1dc3-4a7e-a46f-98d46cfbcb2b', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> | <a href="http://stamen.com">Stamen Design</a> | <a href="https://developer.trimet.org/gis/">TriMet</a>'
}).addTo(map);
var geojsonMarkerOptions = {
radius: 8,
fillColor: "red",
color: "red",
weight: 1,
opacity: 1,
fillOpacity: 0.8
};
// label from https://gis.stackexchange.com/questions/245621/how-to-label-geojson-points-in-leaflet
fetch(
"https://meysohn-sandbox.s3.amazonaws.com/trimet_trip_planner/origin_destination_points.geojson"
)
.then(function (response) {
return response.json();
})
.then(function (data) {
var od_layer = L.geoJSON(data, {
pointToLayer: function (feature, latlng) {
label = String(feature.properties.point_type); // Must convert to string, .bindTooltip can't use straight 'feature.properties.attribute'
return L.circleMarker(latlng, geojsonMarkerOptions)
.bindTooltip(label, { permanent: true, opacity: 0.7 })
.openTooltip();
},
});
od_layer.addTo(map);
map.fitBounds(od_layer.getBounds());
});
</script>
</body>
</html>