-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
797 lines (759 loc) · 25.9 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Metadata -->
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width"
/>
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- Judul pada tab browser -->
<title>LeafletJS</title>
<!-- Bootstrap CSS Library -->
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous"
/>
<!-- Leaflet CSS Library -->
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/leaflet.css"
/>
<!-- Font Awesome CSS Library -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
/>
<!-- Geolocation CSS Library -->
<link
rel="stylesheet"
href="https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-locatecontrol/v0.43.0/L.Control.Locate.css"
/>
<!-- Layer Search CSS Library -->
<link rel="stylesheet" href="plugin/search/leaflet-search.css" />
<!-- Mouse Position CSS Library -->
<link
rel="stylesheet"
href="plugin/cursor-coordinate/L.Control.MousePosition.css"
/>
<!-- Style untuk tampilan peta fullscreen -->
<style>
html,
body {
height: 100%;
width: 100%;
margin: 0px;
}
#map {
height: calc(100% - 56px);
width: 100%;
}
.info {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255, 255, 255, 0.8);
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
border-radius: 5px;
}
.info h2 {
margin: 0 0 5px;
color: #777;
}
.styleLabel {
background: rgba(255, 255, 255, 0);
border: 0;
border-radius: 0px;
box-shadow: 0 0px 0px;
font-size: 10pt;
color: black;
text-shadow: 2px 2px 5px white;
}
.legend {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: rgba(255, 255, 255, 0.8);
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
border-radius: 5px;
}
.legend h4 {
margin: 0 0 5px;
color: #777;
}
.github-fork-ribbon.right-bottom:before {
background-color: #090;
}
.imglegend {
opacity: 0.8;
}
</style>
</head>
<body>
<!-- NavBar -->
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#"
><i class="fa-solid fa-map"></i> Peta DIY</a
>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<!-- Item 1 -->
<li class="nav-item">
<a
class="nav-link active"
aria-current="page"
href="https://github.com/wisnubakso/"
><i class="fa-brands fa-github"></i> GitHub</a
>
</li>
<!-- Item 2 -->
<li class="nav-item">
<a
class="nav-link"
href="#"
data-bs-toggle="modal"
data-bs-target="#infoModal"
><i class="fa-solid fa-circle-info"></i> Info</a
>
</li>
<!-- Item 3 -->
<!-- <li class="nav-item dropdown">
<a
class="nav-link dropdown-toggle"
href="#"
role="button"
data-bs-toggle="dropdown"
aria-expanded="false"
>
</a> -->
<!-- Dropdown -->
<!-- <ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><hr class="dropdown-divider" /></li>
<li>
<a class="dropdown-item" href="#">Something else here</a>
</li>
</ul>
</li> -->
<!-- Item 4 -->
<!-- <li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul> -->
<!-- Search Bar -->
<!-- <form class="d-flex" role="search">
<input
class="form-control me-2"
type="search"
placeholder="Search"
aria-label="Search"
/>
<button class="btn btn-outline-success" type="submit">
</button>
</form> -->
</div>
</div>
</nav>
<!-- HTML Block untuk menampilkan peta -->
<div id="map"></div>
<!-- Info Modal -->
<div
class="modal fade"
id="infoModal"
tabindex="-1"
aria-labelledby="exampleModalLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Info</h1>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">Dibuat pada Pelatihan WebGIS bersama SinauGIS</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary"
data-bs-dismiss="modal"
>
Close
</button>
<!-- <button type="button" class="btn btn-primary">Save changes</button> -->
</div>
</div>
</div>
</div>
<!-- Feature Modal -->
<div class="modal" tabindex="-1" id="featureModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="feature-title"></h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body" id="feature-info">
<p>Modal body text goes here.</p>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary"
data-bs-dismiss="modal"
>
Close
</button>
<!-- <button type="button" class="btn btn-primary">Save changes</button> -->
</div>
</div>
</div>
</div>
<!-- J-Query -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<!-- Bootstrap JS -->
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"
></script>
<!-- Leaflet JavaScript Library -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<!-- Leaflet Label JS Library -->
<script src="https://unpkg.com/[email protected]/rbush.min.js"></script>
<script src="https://unpkg.com/[email protected]/lib/labelgun.min.js"></script>
<script src="plugin/label/leaflet-label.js"></script>
<!-- Geolocation Javascript Library -->
<script src="https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-locatecontrol/v0.43.0/L.Control.Locate.min.js"></script>
<!-- Layer Search JS Library -->
<script src="plugin/search/leaflet-search.js"></script>
<!-- Mouse Position JS Library -->
<script src="plugin/cursor-coordinate/L.Control.MousePosition.js"></script>
<script>
/* Initial Map */
var map = L.map("map").setView([-7.7828715, 110.3670591], 10); //lat, long, zoom
// Disable Leaflet Attribution
map.attributionControl.setPrefix("");
/* Tile Basemap */
var OSM = L.tileLayer(
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
{
//attribution akan muncul di pojok kanan bawah
attribution:
'<a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> | <a href="https://www.unsorry.net" target="_blank">unsorry@2022</a>',
}
);
var GoogleSatellite = L.tileLayer(
"https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}",
{
maxZoom: 20,
subdomains: ["mt0", "mt1", "mt2", "mt3"],
attribution: "Google Satellite",
}
);
var GoogleHybrid = L.tileLayer(
"https://{s}.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
{
maxZoom: 20,
subdomains: ["mt0", "mt1", "mt2", "mt3"],
attribution: "Google Hybrid",
}
);
GoogleSatellite.addTo(map); //Memanggil basemap untuk ditampilkan ketika halaman dipanggil
/* GeoJSON Point */
var titikkabkota = L.geoJson(null, {
pointToLayer: function (feature, latlng) {
return L.marker(latlng, {
icon: L.icon({
iconUrl: "icon/city-marker.png", //icon simbol
iconSize: [28, 28], //ukuran icon simbol
iconAnchor: [14, 28], //penempatan icon simbol
popupAnchor: [0, -28], //penempatan popup terhadap icon simbol
}),
});
},
/* Popup */
onEachFeature: function (feature, layer) {
if (feature.properties) {
/* Variabel untuk memanggil atribut dari data geojson */
var content =
"Kabupaten/Kota : " +
feature.properties.KAB_KOTA +
"<br>" +
"Provinsi : " +
feature.properties.PROVINSI +
"<br>" +
"X :" +
feature.properties.X +
"<br>" +
"Y :" +
feature.properties.Y +
"<br>" +
"Logo : <br>" +
"<img src='logo/" +
feature.properties.LOGO +
"'width='100'>" +
"<br>" +
//Google direction link button//
"<a href='https://www.google.com/maps/dir/?api=1&destination=" +
feature.geometry.coordinates[1] + //Latitude dari GeoJSON
"," +
feature.geometry.coordinates[0] + //Longitude dari GeoJSON
"&travelmode=driving' target='_blank' title='Klik untuk menampilkan rute di google maps'><button>Rute menuju lokasi</button></a>";
layer.on({
click: function (e) {
//Fungsi ketika icon simbol di-klik
titikkabkota.bindPopup(content);
},
});
}
},
});
/* memanggil data geojson point */
$.getJSON("geojson_diy_wisnu/KABKOT.geojson", function (data) {
titikkabkota.addData(data);
map.addLayer(titikkabkota); //titikkabkota ditampilkan ketika halaman dipanggil
});
/* GeoJSON Polyline */
map.createPane("pane_jalanutama");
map.getPane("pane_jalanutama").style.zIndex = 401; //Pane/Layering setting
var jalanutama = L.geoJson(null, {
pane: "pane_jalanutama", //Pane/Layering Setting
/* Style polyline */
style: function (feature) {
//Fungsi style polyline
return {
color: "red", //Warna garis
weight: 1, //Tebal garis
opacity: 1, //Transparansi garis
};
},
/* Highlight & Popup */
onEachFeature: function (feature, layer) {
layer.on({
mouseover: function (e) {
//Fungsi ketika mouse berada di atas obyek
var layer = e.target; //variabel layer
layer.setStyle({
//Highlight style
weight: 2, //Tebal garis
color: "#00FFFF", //Warna garis
opacity: 1, //Transparansi garis
});
},
mouseout: function (e) {
//Fungsi ketika mouse keluar dari area obyek
jalanutama.resetStyle(e.target); //Mengembalikan style garis ke style awal
map.closePopup(); //Menutup popup
},
click: function (e) {
//Fungsi ketika obyek di-klik
var content =
"Keterangan: " +
feature.properties.KETERANGAN +
"<br>" +
"Panjang: " +
feature.properties.PANJANG_KM +
" Km";
jalanutama.bindPopup(content); //Popup
},
});
},
});
/* memanggil data geojson polyline */
$.getJSON("geojson_diy_wisnu/JALAN.geojson", function (data) {
jalanutama.addData(data);
map.addLayer(jalanutama); //jalanutama ditampilkan ketika halaman dipanggil
});
/* GeoJSON Polygon */
var layerColors = {
Tinggi: "#bd0026",
Sedang: "#fd8d3c",
Rendah: "#ffffb2",
}; //layer color categorized
map.createPane("pane_adminkecamatan");
map.getPane("pane_adminkecamatan").style.zIndex = 302; //Pane/Layering setting
var adminkecamatan = L.geoJson(null, {
pane: "pane_adminkecamatan", //Pane/Layering Setting
/* Style polygon */
// // Single Symbol //
// style: function (feature) {
// //Fungsi style polygon
// return {
// fillColor: "blue", //Warna tengah polygon
// fillOpacity: 0.7, //Transparansi tengah polygon
// color: "black", //Warna garis tepi polygon
// weight: 1, //Tebal garis tepi polygon
// opacity: 1, //Transparansi garis tepi polygon
// };
// },
// //Categorized Symbol//
// style: function (feature) {
// //Fungsi style polygon
// return {
// fillColor: layerColors[feature.properties.klas_kpdt], //Warna tengah polygon
// fillOpacity: 0.7, //Transparansi tengah polygon
// color: "black", //Warna garis tepi polygon
// weight: 1, //Tebal garis tepi polygon
// opacity: 1, //Transparansi garis tepi polygon
// };
// },
//Graduated Symbol//
style: function (feature) {
if (feature.properties.JML_PDD <= 50000) {
return {
opacity: 1,
color: "black",
weight: 1.0,
fillOpacity: 0.3,
fillColor: "#ffffb2",
};
}
if (
feature.properties.JML_PDD > 50000 &&
feature.properties.JML_PDD <= 100000
) {
return {
opacity: 1,
color: "black",
weight: 1.0,
fillOpacity: 0.3,
fillColor: "#fd8d3c",
};
}
if (feature.properties.JML_PDD > 100000) {
return {
opacity: 1,
color: "black",
weight: 1.0,
fillOpacity: 0.3,
fillColor: "#bd0026",
};
}
},
/* Highlight & Popup */
onEachFeature: function (feature, layer) {
var content =
"<table class='table table-striped'>" +
"<tr><td>Kabupaten : </td><td>" +
feature.properties.KABUPATEN +
"</td></tr>" +
"<tr><td>Kecamatan : </td><td>" +
feature.properties.KECAMATAN +
"</td></tr>" +
"<tr><td>Jumlah Laki-Laki : </td><td>" +
feature.properties.LAKI_LAKI +
" jiwa </td></tr>" +
"<tr><td>Jumlah Perempuan : </td><td>" +
feature.properties.PEREMPUAN +
" jiwa </td></tr>" +
"<tr><td>Jumlah KK : </td><td>" +
feature.properties.KK +
" KK </td></tr>" +
"<tr><td>Total Penduduk : </td><td>" +
feature.properties.JML_PDD +
" jiwa </td></tr>" +
"<tr><td>Kepadatan Penduduk : </td><td>" +
feature.properties.KPDT_PDD +
" /Km2 </td></tr>" +
"<tr><td>Kriteria Jumlah Penduduk : </td><td>" +
feature.properties.klas_jml +
"</td></tr>" +
"<tr><td>Kriteria Kepadatan Penduduk : </td><td>" +
feature.properties.klas_kpdt +
"</td></tr>" +
"<table>";
layer.on({
mouseover: function (e) {
//Fungsi ketika mouse berada di atas obyek
var layer = e.target; //variabel layer
layer.setStyle({
//Highlight style
weight: 2, //Tebal garis tepi polygon
color: "#00FFFF", //Warna garis tepi polygon
opacity: 1, //Transparansi garis tepi polygon
fillColor: "yellow", //Warna tengah polygon
fillOpacity: 1, //Transparansi tengah polygon
});
},
mouseout: function (e) {
//Fungsi ketika mouse keluar dari area obyek
adminkecamatan.resetStyle(e.target); //Mengembalikan style polygon ke style awal
map.closePopup(); //Menutup popup
},
click: function (e) {
//Fungsi ketika obyek di-klik
// adminkecamatan.bindPopup(content); //BindPopup
$("#feature-title").html("Kec. " + feature.properties.KECAMATAN); //Judul Modal Popup
$("#feature-info").html(content); //Isi Modal Popup
$("#featureModal").modal("show"); //Menampilkan featureModal Popup
},
});
// Labeling
layer.bindTooltip(layer.feature.properties.KECAMATAN.toString(), {
direction: "center",
permanent: true,
className: "styleLabel",
});
},
// filter: function (feature, layer) {
// return (
// feature.properties.KABUPATEN == "Bantul" ||
// feature.properties.KABUPATEN == "Sleman"
// );
// }, //query builder
});
/* memanggil data geojson polygon */
$.getJSON(
"geojson_diy_wisnu/KECAMATAN_PENDUDUK.geojson",
function (data) {
adminkecamatan.addData(data);
map.addLayer(adminkecamatan); //adminkecamatan ditampilkan ketika halaman dipanggil
}
);
// Image Overlay
map.createPane("pane_layerImage");
map.getPane("pane_layerImage").style.zIndex = 201; //Pane/Layering setting
var imgUrl = "images/hillshade.png";
var imgBounds = [
[-8.25, 110.0],
[-7.5, 111.0],
]; //bottom,left,top,right (extent dari data spasial)
var layerImage = new L.imageOverlay(imgUrl, imgBounds, {
pane: "pane_layerImage",
});
// map.addLayer(layerImage); //image overlay ditampilkan ketika halaman dipanggil
layerImage.setOpacity(0.85); //Image transparan
map.fitBounds(layerImage.getBounds()); //Image fitBounds
//WMS Geoserver
map.createPane("pane_wms");
map.getPane("pane_wms").style.zIndex = 301;
var wms = L.tileLayer.wms(
"https://geoportal.slemankab.go.id/geoserver/geonode/wms",
{
layers: "geonode:a__3404_50KB_AR_JUMLAH_PENDUDUK_BERDASARKAN_A",
format: "image/png",
transparent: true,
opacity: 0.8,
attribution: "WMS GeoServer",
pane: "pane_wms",
}
);
// wms.addTo(map); //wms geoserver muncul saat halaman dibuka
//Judul Peta//
var title = new L.Control();
title.onAdd = function (map) {
this._div = L.DomUtil.create("div", "info");
this.update();
return this._div;
};
title.update = function () {
this._div.innerHTML = "<h2>Peta Administrasi</h2>D.I.Yogyakarta";
};
title.addTo(map);
//Reset labels//
resetLabels([adminkecamatan]);
map.on("move", function () {
resetLabels([adminkecamatan]);
});
map.on("zoomend", function () {
resetLabels([adminkecamatan]);
});
map.on("layeradd", function () {
resetLabels([adminkecamatan]);
});
map.on("layerremove", function () {
resetLabels([adminkecamatan]);
});
//Layer Control
var basemaps = {
//list basemap
OSM: OSM,
"Google Satellite": GoogleSatellite,
"Google Hybrid": GoogleHybrid,
};
var Layers = {
//list layer
"Kabupaten/Kota DIY": titikkabkota,
"Jaringan Jalan": jalanutama,
"Admin Kecamatan": adminkecamatan,
"Bayangan Bukit": layerImage,
"WMS Geoserver": wms,
};
var layerControl = L.control.layers(basemaps, Layers, {
collapsed: true,
}); //false : disable/enable collapse pada pilihan basemap
layerControl.addTo(map);
//Cursor's Coordinate//
L.control
.mousePosition({
separator: ",",
prefix: "Koordinat : ",
})
.addTo(map);
//Scale Bar//
L.control
.scale({
maxWidth: 150,
imperial: false,
})
.addTo(map);
//Watermark Logo//
L.Control.Watermark = L.Control.extend({
onAdd: function (map) {
var img = L.DomUtil.create("img");
img.src = "logo/sinaugis.png"; //Image URL
img.style.width = "50px"; //Image Size
return img;
},
onRemove: function (map) {
// Nothing to do here
},
});
L.control.watermark = function (opts) {
return new L.Control.Watermark(opts);
};
L.control.watermark({ position: "bottomleft" }).addTo(map);
// Control legend
var legend = L.control({ position: "bottomleft" }),
legenditem;
legend.onAdd = function (map) {
(this._div = L.DomUtil.create("div", "legend")), (legenditem = []);
this.update();
return this._div;
};
legend.update = function () {
this._div.innerHTML = "<h4>Legend</h4><hr>" + legenditem.join("<hr>");
};
legend.addTo(map);
//Geolocation//
var locateControl = L.control
.locate({
position: "topleft",
drawCircle: true,
follow: true,
setView: true,
keepCurrentZoomLevel: false,
markerStyle: {
weight: 1,
opacity: 0.8,
fillOpacity: 0.8,
},
circleStyle: {
weight: 1,
clickable: false,
},
icon: "fa fa-crosshairs",
metric: true,
strings: {
title: "Klik untuk mengetahui lokasimu",
popup: "Lokasimu sekarang di sini. Akurasi {distance} {unit}",
outsideMapBoundsMsg: "Kamu berada di luar area peta",
},
locateOptions: {
maxZoom: 15,
watch: true,
enableHighAccuracy: true,
maximumAge: 10000,
timeout: 10000,
},
})
.addTo(map);
//Layer Search by Attribute//
// var searchControl = new L.Control.Search({
// layer: adminkecamatan, //Nama variabel layer
// propertyName: "KECAMATAN", //Nama field untuk pencarian (search)
// marker: false,
// position: "topleft",
// moveToLocation: function (latlng, title, map) {
// var zoom = map.getBoundsZoom(latlng.layer.getBounds());
// map.setView(latlng, zoom);
// },
// });
// searchControl
// .on("search:locationfound", function (e) {
// e.layer.setStyle({
// fillColor: "cyan",
// color: "black",
// });
// })
// .on("search:collapsed", function (e) {
// featuresLayer.eachLayer(function (layer) {
// featuresLayer.resetStyle(layer);
// });
// });
// map.addControl(searchControl);
// Legend for each layer//
var legend_titikkabkota =
'<img src="icon/city-marker.png" width="10"> Capital Point',
legend_jalanutama = '<img src="icon/streetlegend.png" width="150">',
legend_adminkecamatan =
'<img src="icon/populationlegend.png" width="150">';
map.on("overlayadd", function (e) {
if (e.layer === titikkabkota) {
legenditem.push(legend_titikkabkota);
legend.update();
}
if (e.layer === jalanutama) {
legenditem.push(legend_jalanutama);
legend.update();
}
if (e.layer === adminkecamatan) {
legenditem.push(legend_adminkecamatan);
legend.update();
}
});
map.on("overlayremove", function (e) {
if (e.layer === titikkabkota) {
for (var i = 0; i < legenditem.length; i++) {
if (legenditem[i] === legend_titikkabkota) {
legenditem.splice(i, 1);
}
}
legend.update();
}
if (e.layer === jalanutama) {
for (var i = 0; i < legenditem.length; i++) {
if (legenditem[i] === legend_jalanutama) {
legenditem.splice(i, 1);
}
}
legend.update();
}
if (e.layer === adminkecamatan) {
for (var i = 0; i < legenditem.length; i++) {
if (legenditem[i] === legend_adminkecamatan) {
legenditem.splice(i, 1);
}
}
legend.update();
}
});
</script>
</body>
</html>