LEAFLET.JS
Dosen Pengampu: Hidayat Panuntun, S. T., M. Eng., D. Sc.
dibuat oleh:
Leonard Eka Satya Nugraha
21/481383/SV/19769
1
DAFTAR ISI
1. JUDUL ........................................................................................................................................................ 3
2. TUJUAN..................................................................................................................................................... 3
3. WAKTU dan TEMPAT ........................................................................................................................... 3
4. ALAT dan BAHAN .................................................................................................................................. 3
5. LANGKAH KERJA dan HASIL ........................................................................................................... 4
6. KESIMPULAN .......................................................................................................................................43
DAFTAR PUSTAKA .....................................................................................................................................44
2
1. JUDUL
Leaflet.JS
2. TUJUAN
3
5. LANGKAH KERJA dan HASIL
4
b. Tampilan Full Screen
Berikut ini merupakan contoh script yang digunakan untuk membuat tampilan peta full
screen 1 halaman web penuh.
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
/>
<style>
body{
padding:0;
margin:0;
}
html,body,#map{
height: 100%;
width: 100%
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js">
</script>
<script>
var map=L.map('map').setView([-7.305421,110.059838],7);
mapLink=
'<a href="http://opensteetmap.org">OpenSteetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
attribution:'Map data©'+mapLink,
maxZoom: 18,
}).addTo(map);
</script>
</body>
</html>
Hasil:
5
Script tersebut akan menampilkan sebuah peta OpenStreetMap. Posisi tampilan peta akan
diatur pada koordinat [-7.305421, 110.059838] dengan tingkat zoom sebesar 7. Script
tersebut juga mengatur tampilan halaman web agar penuh (fullscreen).
6
height: 100%;
width: 100%
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js">
</script>
<script>
var map=L.map('map').setView([-7.305421,110.059838],7);
mapLink=
'<a href="http://opensteetmap.org">OpenSteetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
attribution:'Map data©'+mapLink,
maxZoom: 18,
}).addTo(map);
</script>
</body>
</html>
Hasil:
2) DE
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<link
7
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
/>
<style>
body{
padding:0;
margin:0;
}
html,body,#map{
height: 100%;
width: 100%
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js">
</script>
<script>
var map=L.map('map').setView([-7.305421,110.059838],7);
mapLink=
'<a href="http://opensteetmap.org">OpenSteetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.
png',{
attribution:'Map data©'+mapLink,
maxZoom: 18,
}).addTo(map);
</script>
</body>
Hasil:
8
3) France
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
/>
<style>
body{
padding:0;
margin:0;
}
html,body,#map{
height: 100%;
width: 100%
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js">
</script>
<script>
var map=L.map('map').setView([-7.305421,110.059838],7);
9
mapLink=
'<a href="http://opensteetmap.org">OpenSteetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png'
,{
attribution:'Map data©'+mapLink,
maxZoom: 18,
}).addTo(map);
</script>
</body>
Hasil:
4) Hot
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
/>
<style>
body{
padding:0;
margin:0;
}
html,body,#map{
height: 100%;
width: 100%
10
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js">
</script>
<script>
var map=L.map('map').setView([-7.305421,110.059838],7);
mapLink=
'<a href="http://opensteetmap.org">OpenSteetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',{
attribution:'Map data©'+mapLink,
maxZoom: 18,
}).addTo(map);
</script>
</body>
Hasil:
5) BZH
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
11
/>
<style>
body{
padding:0;
margin:0;
}
html,body,#map{
height: 100%;
width: 100%
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js">
</script>
<script>
var map=L.map('map').setView([-7.305421,110.059838],7);
mapLink=
'<a href="http://opensteetmap.org">OpenSteetMap</a>';
L.tileLayer(
'http://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png',{
attribution:'Map data©'+mapLink,
maxZoom: 18,
}).addTo(map);
</script>
</body>
Hasil:
12
6) Arcgisonline
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
/>
<style>
body{
padding:0;
margin:0;
}
html,body,#map{
height: 100%;
width: 100%
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js">
</script>
<script>
var map=L.map('map').setView([-7.305421,110.059838],7);
mapLink=
13
'<a href="http://opensteetmap.org">OpenSteetMap</a>';
L.tileLayer(
'https://server.arcgisonline.com/ArcGIS/rest/services/Worl
d_Street_Map/MapServer/tile/{z}/{x}/{y}.png',{
attribution:'Map data©'+mapLink,
maxZoom: 18,
}).addTo(map);
</script>
</body>
</html>
Hasil:
7) Topomap
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
/>
<style>
body{
padding:0;
margin:0;
}
html,body,#map{
height: 100%;
14
width: 100%
}
</style>
</head>
<body>
<div id="map"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js">
</script>
<script>
var map=L.map('map').setView([-7.305421,110.059838],7);
mapLink=
'<a href="http://opensteetmap.org">OpenSteetMap</a>';
L.tileLayer(
'http://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',{
attribution:'Map data©'+mapLink,
maxZoom: 18,
}).addTo(map);
</script>
</body>
</html>
Hasil:
8)
d. Marker
Berikut adalah contoh tampilan peta pada script HTML seluruhnya.
<!DOCTYPE html>
<html>
15
<head>
<title>Leaflet Sample</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
crossorigin="" />
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
crossorigin=""></script>
</head>
<body>
<div id="map" style="width: 1200px; height: 580px"></div>
<script>
// Creating map options
var mapOptions = {
center: [-7.62881, 110.401905],
zoom: 15
}
// Creating a map object
var map = L.map('map', mapOptions);
// Creating a Layer object
var layer =
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
// Adding layer to the map
layer.addTo(map);
// Creating a marker
var marker = L.marker([-7.62881, 110.401905]);
// Adding marker to the map
marker.addTo(map);
</script>
</body>
</html>
Hasil:
Script di atas menghasilkan tampilan peta dengan menggunakan marker (point) yang
menunjukkan koordinat (-7.62881, 110.401905).
16
Contoh dengan modifikasi koordinat marker dan mapcenter dengan koordinat daerah
kelahiran asal:
Daerah Desa Karanglo, Kecamatan Tawangmangu, Kabupaten Karanganyar, Jawa Tengah
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Sample</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
crossorigin="" />
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
crossorigin=""></script>
</head>
<body>
<div id="map" style="width: 1200px; height: 580px"></div>
<script>
// Creating map options
var mapOptions = {
center: [-7.665260, 111.089058],
zoom: 15
}
// Creating a map object
var map = L.map('map', mapOptions);
// Creating a Layer object
var layer =
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
17
// Adding layer to the map
layer.addTo(map);
// Creating a marker
var marker = L.marker([ -7.665260, 111.089058]);
// Adding marker to the map
marker.addTo(map);
</script>
</body>
</html>
Hasil:
e. PopUp
Berikut adalah tampilan keseluruhan script HTML-nya:
<!DOCTYPE html>
<html>
<head>
<title>Leaflet sample</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" />
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map" style="width:1200px; height:580px"></div>
<script>
// Creating map options
var mapOptions = {
center: [-7.7743, 110.3746],
18
zoom: 15
};
// Creating a marker
var marker = L.marker([-7.7743, 110.3746]);
f. Marker Options
<!DOCTYPE html>
19
<html>
<head>
<title>Marker Options Example</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
center:[-7.7743, 110.3746],
zoom:18
}
//Creating a map object
var map=new L.map('map',mapOptions);
//Creating a Marker
var markerOptions={
title:"Lokasiku",
clickable:true,
draggable:true
}
// Creating a marker
var marker = L.marker([-7.7743, 110.3746],markerOptions);
</html>
Hasil:
20
g. Marker Custom Icons
<!DOCTYPE html>
<html>
<head>
<title>Marker Options Example</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
center:[-7.905421, 110.059838],
zoom:13
}
//Creating a map object
var map=new L.map('map',mapOptions);
//Icon options
21
var iconOptions={
iconUrl:'https://image.flaticon.com/icons/svg/2114/2114767.sv
g',
iconSize:[75,57]
}
//Creating a custom icon
var customIcon=L.icon(iconOptions);
h. Multiple marker
22
Hasil:
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<meta charset="utf-8"/>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
<script>
var planes=[
["Titik 1",-40.9949,174.50808],
["Titik 2",-41.30269,173.63696],
["Titik 3",-41.49413,173.5421],
["Titik 4",-40.98585,174.50659],
["Titik 5",-40.93163,173.81726],
["Titik 6",-41.5183,174.78081],
["Titik 7",-41.42079,173.5783],
["Titik 8",-42.08414,173.96632],
["Titik 9",-41.51285,173.53274]
];
var map=L.map('map').setView([-41.3058,174.82082],8);
mapLink=
'<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
attibution:'©'+mapLink+'Contributors',
maxZoom:18,
}).addTo(map);
for(var i=0;i<planes.length;i++){
marker=new L.marker([planes[i][1],planes[i][2]])
.bindPopup(planes[i][0])
.addTo(map);
}
</script>
</body>
</html>
Hasil:
23
i. Menambahkan garis
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Polygons</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
center:[-41.2858,174.78682],
zoom:14
}
//Creating a map object
var map=new L.map('map',mapOptions);
24
map.addLayer(layer);
</html>
Hasil:
• Persegi panjang
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Rectangle</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
25
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
center:[16.506174,80.648015],
zoom:7
}
//Creating a map object
var map=new L.map('map',mapOptions);
//Creating a rectangle
var rectangle=L.rectangle(latlngs,rectOptions);
</html>
Hasil:
26
Rectangle yang memutari GSP UGM:
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Rectangle GSP</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
center:[ -7.770150,110.377920],
zoom:17
}
//Creating a map object
var map=new L.map('map',mapOptions);
27
var layer=new
L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
//Creating a rectangle
var rectangle=L.rectangle(latlngs,rectOptions);
</html>
Hasil:
• Lingkaran
<!DOCTYPE html>
28
<html>
<head>
<title>Leaflet Rectangle</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
center:[-7.905421,110.059838],
zoom:10
}
//Creating a map object
var map=new L.map('map',mapOptions);
//Circle options
var circleOptions={
color:'red',
fillColor:'#f03',
fillOpacity:0
}
//Creating a circle
var circle=L.circle(circleCenter,5000,circleOptions);
</html>
29
Hasil:
j. Event Handling
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Polygon</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
center:[-7.905421,110.059838],
zoom:10
}
//Creating a map object
var map=new L.map('map',mapOptions);
30
var layer=new
L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
map.om("click",function(e){
new L.Marker([e.latlng.lat,e.latlng.lng]).addTo(map);
})
</script>
</body>
</html>
Hasil:
k. Skala
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Rectangle</title>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
31
center:[-7.905421,110.059838],
zoom:10
}
//Creating a map object
var map=new L.map('map',mapOptions);
32
<title>Simple Leaflet Map</title>
<meta charset="utf-8" />
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
crossorigin="" />
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
crossorigin=""></script>
</head>
<body>
<div id="map" style="width: 900px; height: 400px"></div>
<script>
var osmLink = '<a
href="http://openstreetmap.org">OpenStreetMap</a>',
thunLink = '<a href="http://thunderforest.com/">Thunderforest</a>';
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmAttrib = '© '+osmLink+' Contributors',
landUrl =
'http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png',
thunAttrib = '© '+osmLink+' Contributors & '+thunLink;
var osmMap = L.tileLayer(osmUrl, {attribution: osmAttrib}),
landMap = L.tileLayer(landUrl, {attribution: thunAttrib});
var map = L.map('map', {
layers: [osmMap] // only add one!
}).setView([-7.305421, 110.059838], 7);
var baseLayers = {
"OSM Mapnik": osmMap,
"Landscape": landMap
};
L.control.layers(baseLayers).addTo(map);
</script>
</body>
</html>
Hasil:
33
m. Leaflet plugin
<!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet</title>
<meta charset="utf-8"/>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
/>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/k4r573n/leaflet-control-osm-
geocoder/src/Control.OSMGeocoder.css" />
34
</head>
<body>
<div id="map" style="width:1100px;height:800px"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
<script src="https://cdn.jsdelivr.net/gh/k4r573n/leaflet-control-
osm-geocoder/src/Control.OSMGeocoder.js"></script>
<script>
var map = L.map('map').setView([-7.805421, 110.379838], 13);
var mapLink = '<a
href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
, {
attribution: '© ' + mapLink + ' Contributors',
maxZoom: 18,
}).addTo(map);
Tugas:
35
1. Dengan menggunakan marker, buatlah peta persebaran lokasi: (a) kantong parkir sepeda UGM
di UGM, (b) Tempat makan di sekitar area SV UGM (Sendowo dan sekitarnya). Gunakan
simbolisasi yang berbeda-beda untuk tiap marker yang digunakan.
Jawab:
a. Pos parkir sepeda UGM
<!DOCTYPE html>
<html>
<head>
<title>Pos parkir</title>
<meta charset="utf-8"/>
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
<script>
var planes=[
["Titik Parkir 1", -7.769417,110.377480],
["Titik Parkir 2",- -7.771587,110.378540],
["Titik Parkir 3", -7.774606,110.374440],
["Titik parkir 4", -7.771310,110.375803],
["Titik Parkir 5", -7.768294,110.375836],
["Titik Parkir 6", -7.768017,110.376817],
["Titik Parkir 7", -7.775258,110.380006],
["Titik parkir 8", -7.768603,110.386645],
["Titik Parkir 9", -7.766601,110.382535],
["Titik Parkir 10", -7.770403,110.381781],
["Titik Parkir 11", -7.764645,110.377439],
["Titik Parkir 12", -7.766175,110.374506]
];
var map=L.map('map').setView([ -7.770150,110.377920],8);
mapLink=
'<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
attibution:'©'+mapLink+'Contributors',
maxZoom:18,
}).addTo(map);
for(var i=0;i<planes.length;i++){
marker=new L.marker([planes[i][1],planes[i][2]])
.bindPopup(planes[i][0])
36
.addTo(map);
}
</script>
</body>
</html>
Hasil:
37
["Tempat Makan 8",-7.7735, 110.3728]
];
var map=L.map('map').setView([ -
7.774637721423318,110.3740340171671],14);
mapLink=
'<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
attibution:'©'+mapLink+'Contributors',
maxZoom:18,
}).addTo(map);
for(var i=0;i<planes.length;i++){
marker=new L.marker([planes[i][1],planes[i][2]])
.bindPopup(planes[i][0])
.addTo(map);
}
</script>
</body>
</html>
Hasil:
38
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"/>
<script
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
</head>
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
center:[-7.774615,110.373955],
zoom:18
}
//Creating a map object
var map=new L.map('map',mapOptions);
</html>
</script>
39
Hasil:
<body>
<div id="map"style="width:900px;height:580px"></div>
<script>
//Creating map options
var mapOptions={
center:[ -7.770150,110.377920],
zoom:14
}
//Creating a map object
var map=new L.map('map',mapOptions);
40
map.addLayer(layer);
];
//Creating a polygon
var polygon=L.polygon(latlngs,{color:'red'});
41
</html>
</script>
Hasil:
42
6. KESIMPULAN
Pada praktikum pada kali ini dapat diperoleh kesimpulan sebagai berikut:
1. Leaflet adalah sebuah pustaka JavaScript yang digunakan untuk membuat peta interaktif di
web. Pustaka ini dapat digunakan dengan mudah dan fleksibel.
2. Peta yang dibuat dengan Leaflet dapat diberi berbagai macam tampilan, seperti tampilan street
view, satellite, terrain, dan masih banyak lagi. Leaflet menyediakan banyak sekali fitur dan
fungsi untuk mempermudah pembuatan peta interaktif, seperti fitur zoom in dan zoom out,
fitur marker, fitur polyline, dan masih banyak lagi.
3. Leaflet juga memiliki plugin-plugin yang dapat digunakan untuk menambahkan fitur-fitur
tambahan pada peta interaktif yang dibuat.
4. Pada praktikum Leaflet javascript map, kita belajar cara membuat peta interaktif sederhana
dengan menggunakan Leaflet. Kita dapat memasukkan data koordinat dan informasi pada
setiap titik pada peta.
5. Pada praktikum tersebut, kita juga belajar bagaimana cara menambahkan layer pada peta dan
menampilkan data GeoJSON pada peta Leaflet.
6. Dalam pembuatan peta interaktif dengan Leaflet, perlu diingat bahwa tampilan peta dan
interaksi pengguna dengan peta harus dipertimbangkan dengan baik agar dapat memberikan
pengalaman pengguna yang baik.
43
DAFTAR PUSTAKA
Edler, D., & Vetter, M. (2019). The simplicity of modern audiovisual web cartography: An example
with the open-source javascript library leaflet. js. KN-Journal of Cartography and Geographic Information, 69,
51-62.
Horbiński, T., & Lorek, D. (2022). The use of Leaflet and GeoJSON files for creating the interactive
web map of the preindustrial state of the natural environment. Journal of Spatial Science, 67(1), 61-77.
Wang, L., Pi, R., Zhou, X., & Zhou, H. (2015, November). The construction of off-line map based
on OpenStreetMap and leaflet. In 4th International Conference on Computer, Mechatronics, Control and
Electronic Engineering (pp. 1471-1475). Atlantis Press.
44