289 lines
7.1 KiB
HTML
289 lines
7.1 KiB
HTML
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Kepadatan Penduduk Pontianak - Choropleth Map</title>
|
|
|
|
<!-- Google Fonts -->
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
|
|
<!-- Leaflet CSS -->
|
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
|
|
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
|
|
|
<style>
|
|
body, html {
|
|
margin: 0;
|
|
padding: 0;
|
|
height: 100%;
|
|
font-family: 'Inter', sans-serif;
|
|
overflow: hidden;
|
|
background-color: #f8fafc;
|
|
}
|
|
|
|
#map {
|
|
width: 100vw;
|
|
height: 100vh;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
z-index: 1;
|
|
}
|
|
|
|
/* Brand panel overlay */
|
|
.brand-panel {
|
|
position: absolute;
|
|
top: 20px;
|
|
left: 20px;
|
|
z-index: 1000;
|
|
background: rgba(255, 255, 255, 0.9);
|
|
backdrop-filter: blur(8px);
|
|
border: 1px solid rgba(191, 219, 254, 0.6);
|
|
padding: 20px;
|
|
border-radius: 16px;
|
|
box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
|
|
max-width: 320px;
|
|
transition: all 0.3s ease;
|
|
}
|
|
.brand-panel:hover {
|
|
box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15), 0 10px 10px -5px rgba(0,0,0,0.08);
|
|
border-color: rgba(29, 78, 216, 0.3);
|
|
}
|
|
.brand-title {
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
color: #1e293b;
|
|
margin-bottom: 6px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
.brand-title svg {
|
|
color: #1d4ed8;
|
|
}
|
|
.brand-subtitle {
|
|
font-size: 13px;
|
|
color: #64748b;
|
|
margin-bottom: 16px;
|
|
line-height: 1.5;
|
|
}
|
|
.btn-back {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: #1d4ed8;
|
|
background: #eff6ff;
|
|
border: 1px solid #bfdbfe;
|
|
padding: 10px 16px;
|
|
border-radius: 10px;
|
|
text-decoration: none;
|
|
transition: all 0.2s ease;
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
justify-content: center;
|
|
}
|
|
.btn-back:hover {
|
|
background: #dbeafe;
|
|
color: #1e40af;
|
|
transform: translateY(-1px);
|
|
}
|
|
.btn-back svg {
|
|
width: 16px;
|
|
height: 16px;
|
|
}
|
|
|
|
/* Custom Info Box style */
|
|
.info {
|
|
padding: 12px 18px;
|
|
font-family: 'Inter', sans-serif;
|
|
background: rgba(255, 255, 255, 0.9) !important;
|
|
backdrop-filter: blur(8px);
|
|
border: 1px solid rgba(191, 219, 254, 0.8) !important;
|
|
box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.08) !important;
|
|
border-radius: 14px !important;
|
|
color: #1e293b;
|
|
min-width: 200px;
|
|
}
|
|
.info h4 {
|
|
margin: 0 0 6px;
|
|
color: #64748b;
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
.info b {
|
|
color: #1e293b;
|
|
font-size: 15px;
|
|
font-weight: 700;
|
|
}
|
|
.info-desc {
|
|
font-size: 13px;
|
|
color: #475569;
|
|
margin-top: 4px;
|
|
}
|
|
|
|
/* Custom Legend style */
|
|
.legend {
|
|
line-height: 22px;
|
|
color: #475569;
|
|
font-family: 'Inter', sans-serif;
|
|
font-size: 12px;
|
|
padding: 14px 18px;
|
|
background: rgba(255, 255, 255, 0.9) !important;
|
|
backdrop-filter: blur(8px);
|
|
border: 1px solid rgba(191, 219, 254, 0.8) !important;
|
|
box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.08) !important;
|
|
border-radius: 14px !important;
|
|
}
|
|
.legend i {
|
|
width: 18px;
|
|
height: 18px;
|
|
float: left;
|
|
margin-right: 10px;
|
|
opacity: 0.85;
|
|
border-radius: 4px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="brand-panel">
|
|
<div class="brand-title">
|
|
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>
|
|
Kepadatan Penduduk
|
|
</div>
|
|
<div class="brand-subtitle">Visualisasi choropleth spasial jumlah penduduk per kecamatan di Kota Pontianak.</div>
|
|
<a href="../index.php" class="btn-back">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>
|
|
Kembali ke Portal
|
|
</a>
|
|
</div>
|
|
|
|
<div id="map"></div>
|
|
|
|
<!-- GeoJSON Data -->
|
|
<script type="text/javascript" src="pontianakk.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
// Inisialisasi peta
|
|
const map = L.map('map', { zoomControl: false }).setView([-0.02, 109.34], 12);
|
|
|
|
// Tambahkan tombol zoom di kanan bawah agar tidak bertabrakan dengan brand panel
|
|
L.control.zoom({ position: 'bottomright' }).addTo(map);
|
|
|
|
const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
maxZoom: 19,
|
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
}).addTo(map);
|
|
|
|
// Info control (hover)
|
|
const info = L.control();
|
|
|
|
info.onAdd = function (map) {
|
|
this._div = L.DomUtil.create('div', 'info');
|
|
this.update();
|
|
return this._div;
|
|
};
|
|
|
|
info.update = function (props) {
|
|
const contents = props
|
|
? `<b>Kec. ${props.name}</b><br /><div class="info-desc">${props.civilians.toLocaleString('id-ID')} jiwa</div>`
|
|
: '<div class="info-desc">Hover ke kecamatan</div>';
|
|
this._div.innerHTML = `<h4>Info Kependudukan</h4>${contents}`;
|
|
};
|
|
|
|
info.addTo(map);
|
|
|
|
// Warna gradien berdasarkan jumlah penduduk
|
|
function getColor(d) {
|
|
return d > 140000 ? '#800026' :
|
|
d > 120000 ? '#BD0026' :
|
|
d > 100000 ? '#E31A1C' :
|
|
d > 80000 ? '#FC4E2A' :
|
|
d > 60000 ? '#FD8D3C' :
|
|
d > 50000 ? '#FEB24C' :
|
|
'#FFEDA0';
|
|
}
|
|
|
|
function style(feature) {
|
|
return {
|
|
weight: 2.5,
|
|
opacity: 1,
|
|
color: 'white',
|
|
dashArray: '3',
|
|
fillOpacity: 0.75,
|
|
fillColor: getColor(feature.properties.civilians)
|
|
};
|
|
}
|
|
|
|
function highlightFeature(e) {
|
|
const layer = e.target;
|
|
|
|
layer.setStyle({
|
|
weight: 4,
|
|
color: '#1d4ed8',
|
|
dashArray: '',
|
|
fillOpacity: 0.85
|
|
});
|
|
|
|
layer.bringToFront();
|
|
info.update(layer.feature.properties);
|
|
}
|
|
|
|
const geojson = L.geoJson(pontianakData, {
|
|
style,
|
|
onEachFeature
|
|
}).addTo(map);
|
|
|
|
function resetHighlight(e) {
|
|
geojson.resetStyle(e.target);
|
|
info.update();
|
|
}
|
|
|
|
function zoomToFeature(e) {
|
|
map.fitBounds(e.target.getBounds());
|
|
}
|
|
|
|
function onEachFeature(feature, layer) {
|
|
layer.on({
|
|
mouseover: highlightFeature,
|
|
mouseout: resetHighlight,
|
|
click: zoomToFeature
|
|
});
|
|
}
|
|
|
|
// Legend control
|
|
const legend = L.control({position: 'bottomright'});
|
|
|
|
legend.onAdd = function (map) {
|
|
const div = L.DomUtil.create('div', 'info legend');
|
|
const grades = [50000, 60000, 80000, 100000, 120000, 140000];
|
|
const labels = [];
|
|
let from, to;
|
|
|
|
labels.push('<strong>Jiwa / Kecamatan</strong><br><br>');
|
|
for (let i = 0; i < grades.length; i++) {
|
|
from = grades[i];
|
|
to = grades[i + 1];
|
|
|
|
labels.push(
|
|
`<i style="background:${getColor(from + 1)}"></i> ` +
|
|
`${from.toLocaleString('id-ID')}${to ? ` – ${to.toLocaleString('id-ID')}` : '+'}`
|
|
);
|
|
}
|
|
|
|
div.innerHTML = labels.join('<br>');
|
|
return div;
|
|
};
|
|
|
|
legend.addTo(map);
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|