-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlayer-group.html
96 lines (72 loc) · 2.95 KB
/
layer-group.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
<!DOCTYPE html>
<html lang="en">
<head>
<base target="_top">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Layers Control Tutorial - Leaflet</title>
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<style>
.map {
height: 100vh;
width: 100%;
}
</style>
</head>
<body>
<div class="map" id='map'></div>
<script>
const distrik = L.layerGroup();
const Abepura = L.marker([-2.76199527699993, 140.686465844999987]).bindPopup('Distrik Abepura').addTo(distrik);
const Heram = L.marker([-2.640000, 140.700000]).bindPopup('Distrik Heram').addTo(distrik);
const JayapuraUtara = L.marker([-2.53371, 140.71813]).bindPopup('Distrik Jayapura Utara').addTo(distrik);
const MuaraTami = L.marker([-2.60000, 140.66667]).bindPopup('Distrik Muara Tami').addTo(distrik);
const osm = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});
const map = L.map('map', {
center: [-2.53371, 140.71813],
zoom: 12,
layers: [osm, distrik]
});
const baseLayers = {
'OpenStreetMap': osm
};
const overlays = {
'Distrik': distrik,
};
const layerControl = L.control.layers(baseLayers, overlays).addTo(map);
const kelurahan = L.layerGroup();
const vimIcon = L.icon({
iconUrl: 'assets/img/pin-home-green.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34]
});
const vim = L.marker([-2.595713, 140.6597402], {icon: vimIcon}).bindPopup('Kelurahan Vim').addTo(kelurahan);
const wahnoIcon = L.icon({
iconUrl: 'assets/img/pin-home-green.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34]
});
const wahno = L.marker([-2.593637, 140.6688757], {icon: wahnoIcon}).bindPopup('Kelurahan Wahno').addTo(kelurahan);
const heramIcon = L.icon({
iconUrl: 'assets/img/pin-home-green.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34]
});
const heram = L.marker([-2.6369492, 140.4933969], {icon: heramIcon}).bindPopup('Kelurahan Heram').addTo(kelurahan);
const openTopoMap = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: 'Map data: © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: © <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
});
// layerControl.addBaseLayer(openTopoMap, 'OpenTopoMap');
layerControl.addOverlay(kelurahan, 'Kelurahan');
</script>
</body>
</html>