forked from sifsuska/bootleaf-faste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
1273 lines (1092 loc) · 38.8 KB
/
app.js
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
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var map, featureList, boroughSearch = [], theaterSearch = [], museumSearch = [];
//untuk menampung pencarian
var fst_lt1Search=[],fst_lt2Search=[],fst_lt3Search=[]
,gb_lt1Search=[],gb_lt2Search=[],gb_lt3Search=[]
,kantinSearch=[]
,lab_fst_lt1Search=[],lab_fst_lt2Search=[]
,psi_lt1Search=[],psi_lt2Search=[]
,tamanSearch=[];
//untuk menampung array semua layer yang masuk ke POI di pojok kiri
var sidebarLayers=[];
$(window).resize(function() {
sizeLayerControl();
});
$(document).on("click", ".feature-row", function(e) {
$(document).off("mouseout", ".feature-row", clearHighlight);
//sidebarClick(parseInt($(this).attr("id"), 10));
sidebarClick($(this).attr("lat"),$(this).attr("lng"));
});
if ( !("ontouchstart" in window) ) {
$(document).on("mouseover", ".feature-row", function(e) {
highlight.clearLayers().addLayer(L.circleMarker([$(this).attr("lat"), $(this).attr("lng")], highlightStyle));
});
}
$(document).on("mouseout", ".feature-row", clearHighlight);
$("#about-btn").click(function() {
$("#aboutModal").modal("show");
$(".navbar-collapse.in").collapse("hide");
return false;
});
$("#full-extent-btn").click(function() {
map.fitBounds(boroughs.getBounds());
$(".navbar-collapse.in").collapse("hide");
return false;
});
$("#legend-btn").click(function() {
$("#legendModal").modal("show");
$(".navbar-collapse.in").collapse("hide");
return false;
});
$("#login-btn").click(function() {
$("#loginModal").modal("show");
$(".navbar-collapse.in").collapse("hide");
return false;
});
$("#list-btn").click(function() {
animateSidebar();
return false;
});
$("#nav-btn").click(function() {
$(".navbar-collapse").collapse("toggle");
return false;
});
$("#sidebar-toggle-btn").click(function() {
animateSidebar();
return false;
});
$("#sidebar-hide-btn").click(function() {
animateSidebar();
return false;
});
function animateSidebar() {
$("#sidebar").animate({
width: "toggle"
}, 350, function() {
map.invalidateSize();
});
}
function sizeLayerControl() {
$(".leaflet-control-layers").css("max-height", $("#map").height() - 50);
}
function clearHighlight() {
highlight.clearLayers();
}
//function sidebarClick(id) {
function sidebarClick(lat,lng) {
//var layer = markerClusters.getLayer(id);
//map.setView([layer.getLatLng().lat, layer.getLatLng().lng], 17);
map.setView([lat, lng], 21);
//layer.fire("click");
/* Hide sidebar and go to the map on small screens */
if (document.body.clientWidth <= 767) {
$("#sidebar").hide();
map.invalidateSize();
}
}
function syncSidebar() {
/* Empty sidebar features */
//$("#feature-list tbody").empty();
/* Loop through theaters layer and add only features which are in the map bounds */
// theaters.eachLayer(function (layer) {
// if (map.hasLayer(theaterLayer)) {
// if (map.getBounds().contains(layer.getLatLng())) {
// $("#feature-list tbody").append('<tr class="feature-row" id="' + L.stamp(layer) + '" lat="' + layer.getLatLng().lat + '" lng="' + layer.getLatLng().lng + '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">' + layer.feature.properties.NAME + '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
// }
// }
// });
/* Loop through museums layer and add only features which are in the map bounds */
// museums.eachLayer(function (layer) {
// if (map.hasLayer(museumLayer)) {
// if (map.getBounds().contains(layer.getLatLng())) {
// $("#feature-list tbody").append('<tr class="feature-row" id="' + L.stamp(layer) + '" lat="' + layer.getLatLng().lat + '" lng="' + layer.getLatLng().lng + '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/museum.png"></td><td class="feature-name">' + layer.feature.properties.NAME + '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
// }
// }
// });
/* Update list.js featureList */
////// featureList = new List("features", {
////// valueNames: ["feature-name"]
////// });
////// featureList.sort("feature-name", {
////// order: "asc"
////// });
}
/* Basemap Layers */
var carto_positron_lite_rainbow = L.tileLayer(
"https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_nolabels/{z}/{x}/{y}.png",{
subdomains:"abcd",
attribution:'© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 18
});
var carto_label = L.tileLayer(
"https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_only_labels/{z}/{x}/{y}.png",{
subdomains:"abcd",
maxZoom:18
});
var cartoLight = L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png", {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="https://cartodb.com/attributions">CartoDB</a>'
});
/* var usgsImagery = L.layerGroup([L.tileLayer("http://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}", {
maxZoom: 15,
}), L.tileLayer.wms("http://raster.nationalmap.gov/arcgis/services/Orthoimagery/USGS_EROS_Ortho_SCALE/ImageServer/WMSServer?", {
minZoom: 16,
maxZoom: 19,
layers: "0",
format: 'image/jpeg',
transparent: true,
attribution: "Aerial Imagery courtesy USGS"
})]); */
/* Overlay Layers */
var highlight = L.geoJson(null);
var highlightStyle = {
stroke: false,
fillColor: "#00FFFF",
fillOpacity: 0.7,
radius: 10
};
//menampung variabel warna
var ruangColors={
"Lab":"rgba(40,96,144,1.0)",
"Fasum":"rgba(234,137,150,1.0)",
"Admin" : "rgba(228,243,98,1.0)",
"Perpus" : "rgba(121,185,0,1.0)",
"Dosen" : "rgba(184,71,255,1.0)",
"Belajar" : "rgba(237,66,36,1.0)",
};
function style_ruang(feature) {
return {
opacity: 1,
color: 'rgba(0,0,0,0.1)',
dashArray: '',
lineCap: 'butt',
lineJoin: 'miter',
weight: 3.0,
fillOpacity: 1,
fillColor: ruangColors[feature.properties['tipe']]
};
}
// GEDUNG DEKANAT FASTE
var fst_lt1 = L.geoJson(null, {
style: style_ruang,
onEachFeature: function (feature, layer) {
//untuk search, push masing-masing fitur ke array kita
fst_lt1Search.push({
name: layer.feature.properties.nama,
source: "FST Lantai 1",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/fst_lt1.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
fst_lt1.addData(data);
});
var fst_lt2 = L.geoJson(null, {
/*style: function (feature) {
return {
color: "black",
////fill: false,
opacity: 1,
clickable: true
};
}, */
style: style_ruang,
onEachFeature: function (feature, layer) {
fst_lt2Search.push({
name: layer.feature.properties.nama,
source: "FST Lantai 2",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/fst_lt2.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
fst_lt2.addData(data);
});
var fst_lt3 = L.geoJson(null, {
/*style: function (feature) {
return {
color: "green",
//fill: false,
opacity: 1,
clickable: true
};
}, */
style: style_ruang,
onEachFeature: function (feature, layer) {
fst_lt3Search.push({
name: layer.feature.properties.nama,
source: "FST Lantai 3",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/fst_lt3.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
fst_lt3.addData(data);
});
// Gedung Baru
var gb_lt1 = L.geoJson(null, {
style: style_ruang,
onEachFeature: function (feature, layer) {
gb_lt1Search.push({
name: layer.feature.properties.nama,
source: "Gedung Baru Lantai 1",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/gb_lt1.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
gb_lt1.addData(data);
});
var gb_lt2 = L.geoJson(null, {
/*style: function (feature) {
return {
color: "green",
//fill: false,
opacity: 1,
clickable: true
};
}, */
style: style_ruang,
onEachFeature: function (feature, layer) {
gb_lt2Search.push({
name: layer.feature.properties.nama,
source: "Gedung Baru Lantai 2",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/gb_lt2.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
gb_lt2.addData(data);
});
var gb_lt3 = L.geoJson(null, {
style: style_ruang,
onEachFeature: function (feature, layer) {
gb_lt3Search.push({
name: layer.feature.properties.nama,
source: "Gedung Baru Lantai 3",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/gb_lt3.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
gb_lt3.addData(data);
});
// kantin
var kantin = L.geoJson(null, {
style: style_ruang,
onEachFeature: function (feature, layer) {
kantinSearch.push({
name: layer.feature.properties.nama,
source: "Kantin",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/kantin.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
kantin.addData(data);
});
// lab_fst
var lab_fst_lt1 = L.geoJson(null, {
style: style_ruang,
onEachFeature: function (feature, layer) {
lab_fst_lt1Search.push({
name: layer.feature.properties.nama,
source: "Lab Lantai 1",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/lab_fst_lt1.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
lab_fst_lt1.addData(data);
});
var lab_fst_lt2 = L.geoJson(null, {
style: style_ruang,
onEachFeature: function (feature, layer) {
lab_fst_lt2Search.push({
name: layer.feature.properties.nama,
source: "Lab Lantai 2",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/lab_fst_lt2.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
lab_fst_lt2.addData(data);
});
// PSI
var psi_lt1 = L.geoJson(null, {
style: style_ruang,
onEachFeature: function (feature, layer) {
psi_lt1Search.push({
name: layer.feature.properties.nama,
source: "PSI Lantai 1",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/psi_lt1.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
psi_lt1.addData(data);
});
var psi_lt2 = L.geoJson(null, {
style: style_ruang,
onEachFeature: function (feature, layer) {
psi_lt2Search.push({
name: layer.feature.properties.nama,
source: "PSI Lantai 2",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/psi_lt2.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
psi_lt2.addData(data);
});
//menambahkan taman
var taman = L.geoJson(null, {
style: style_ruang,
onEachFeature: function (feature, layer) {
//untuk search, push masing-masing fitur ke array kita
tamanSearch.push({
name: layer.feature.properties.nama,
source: "Taman Cinta",
id: L.stamp(layer),
bounds: layer.getBounds()
});
//untuk di klik nampilin modal
var content = "<table class='table table-striped table-bordered table-condensed'>"
+ "<tr><th>Nama Ruang</th><td>" + feature.properties.nama + "</td></tr>"
+ "<tr><th>Luas</th><td>" + feature.properties.area + " m<sup>2</sup></td></tr>"
+ "<tr><th>Gambar</th><td>" + feature.properties.pict + "</td></tr>"
+ "<table>";
layer.on({
click: function (e) {
$("#feature-title").html(feature.properties.nama);
$("#feature-info").html(content);
$("#featureModal").modal("show");
}
});
//untuk POI list
$("#feature-list tbody").append('<tr class="feature-row" id="'
+ L.stamp(layer)
+ '" lat="'+feature.geometry.coordinates[0][0][1]
+ '" lng="' +feature.geometry.coordinates[0][0][0]
+ '" bounds="' +layer.getBounds()
+ '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">'
+ layer.feature.properties.nama
+ '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>');
}
});
//load geojson kita dengan jQuery
$.getJSON("data/taman.geojson", function (data) {
//tambahkan ke layer Leaflet yang tadinya masih null
taman.addData(data);
});
/* Single marker cluster layer to hold all clusters */
var markerClusters = new L.MarkerClusterGroup({
spiderfyOnMaxZoom: true,
showCoverageOnHover: false,
zoomToBoundsOnClick: true,
disableClusteringAtZoom: 16
});
map = L.map("map", {
zoom: 18,
center: [0.468057, 101.355697], // center di 101.35569777220351, 0.468057021493219
// default layers on
layers: [fst_lt1, gb_lt1, kantin,lab_fst_lt1, psi_lt1, taman],
zoomControl: false,
// we have our own attributionControl
attributionControl: false
});
/* Layer control listeners that allow for a single markerClusters layer */
map.on("overlayadd", function(e) {
//if (e.layer === theaterLayer) {
// markerClusters.addLayer(theaters);
// syncSidebar();
//}
//if (e.layer === museumLayer) {
// markerClusters.addLayer(museums);
// syncSidebar();
//}
// karena semuanya ditambahkan ... ngga usah pake if if an
//markerClusters.addLayer(e.layer);
//syncSidebar();
});
map.on("overlayremove", function(e) {
//if (e.layer === theaterLayer) {
// markerClusters.removeLayer(theaters);
// syncSidebar();
//}
//if (e.layer === museumLayer) {
// markerClusters.removeLayer(museums);
// syncSidebar();
//}
//markerClusters.removeLayer(e.layer);
//syncSidebar();
});
/* Filter sidebar feature list to only show features in current map bounds */
map.on("moveend", function (e) {
//syncSidebar();
});
/* Clear feature highlight when map is clicked */
map.on("click", function(e) {
highlight.clearLayers();
});
/* Attribution control */
function updateAttribution(e) {
$.each(map._layers, function(index, layer) {
if (layer.getAttribution) {
$("#attribution").html((layer.getAttribution()));
}
});
}
map.on("layeradd", updateAttribution);
map.on("layerremove", updateAttribution);
var attributionControl = L.control({
position: "bottomright"
});
attributionControl.onAdd = function (map) {
var div = L.DomUtil.create("div", "leaflet-control-attribution");
div.innerHTML = "<span class='hidden-xs'>Developed by <a href='http://sifsuska.github.io'>SIFsuska</a> | </span><a href='#' onclick='$(\"#attributionModal\").modal(\"show\"); return false;'>Attribution</a>";
return div;
};
map.addControl(attributionControl);
var zoomControl = L.control.zoom({
position: "bottomright"
}).addTo(map);
/* GPS enabled geolocation control set to follow the user's location */
var locateControl = L.control.locate({
position: "bottomright",
drawCircle: true,
follow: true,
setView: true,
keepCurrentZoomLevel: true,
markerStyle: {
weight: 1,
opacity: 0.8,
fillOpacity: 0.8
},
circleStyle: {
weight: 1,
clickable: false
},
icon: "fa fa-location-arrow",
metric: false,
strings: {
title: "My location",
popup: "You are within {distance} {unit} from this point",
outsideMapBoundsMsg: "You seem located outside the boundaries of the map"
},
locateOptions: {
maxZoom: 18,
watch: true,
enableHighAccuracy: true,
maximumAge: 10000,
timeout: 10000
}
}).addTo(map);
/* Larger screens get expanded layer control and visible sidebar */
if (document.body.clientWidth <= 767) {
var isCollapsed = true;
} else {
var isCollapsed = false;
}
var baseLayers = {
"Street Map": cartoLight,
//"Aerial Imagery": usgsImagery,
"Carto Positron": carto_positron_lite_rainbow
};
var groupedOverlays = {
"Dekanat": {
"Labels": carto_label,
"Lantai 1": fst_lt1,
"Lantai 2": fst_lt2,
"Lantai 3": fst_lt3
},
"Gedung Baru": {
"Lantai 1": gb_lt1,
"Lantai 2": gb_lt2,
"Lantai 3": gb_lt3
},
"Lab":{
"Lantai 1": lab_fst_lt1,
"Lantai 2": lab_fst_lt2
},
"PSI":{
"Lantai 1": psi_lt1,
"Lantai 2": psi_lt2,
"Kantin": kantin
}
};
var layerControl = L.control.groupedLayers(baseLayers, groupedOverlays, {
collapsed: isCollapsed
}).addTo(map);
/* Highlight search box text on click */
$("#searchbox").click(function () {
$(this).select();
});
/* Prevent hitting enter from refreshing the page */
$("#searchbox").keypress(function (e) {
if (e.which == 13) {
e.preventDefault();
}
});
$("#featureModal").on("hidden.bs.modal", function (e) {
$(document).on("mouseout", ".feature-row", clearHighlight);
});
/* Typeahead search functionality */
$(document).one("ajaxStop", function () {
$("#loading").hide();
sizeLayerControl();
/* Fit map to bounds */
map.fitBounds(fst_lt1.getBounds());
//perhatikan bahwa kodingan di atas dapat mengganggu center map kita
featureList = new List("features", {valueNames: ["feature-name"]});
featureList.sort("feature-name", {order:"asc"});
//untuk searching
var fst_lt1BH = new Bloodhound({
name: "Faste Lantai 1",
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.name);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: fst_lt1Search,
limit: 10
});
fst_lt1BH.initialize();
var fst_lt2BH = new Bloodhound({
name: "Faste Lantai 2",
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.name);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: fst_lt2Search,
limit: 10
});
fst_lt2BH.initialize();