First commit / commit pertama

This commit is contained in:
Mr.Haruna
2026-06-13 11:24:58 +07:00
commit 522c4f7200
166 changed files with 13326 additions and 0 deletions
+364
View File
@@ -0,0 +1,364 @@
/* =========================================================
ADMIN LAYOUT STYLES — sidebar, topbar, main content
========================================================= */
body.admin-page {
display: flex;
min-height: 100vh;
background: var(--bg-base);
}
/* ══════════════════════════════
SIDEBAR
══════════════════════════════ */
.sidebar {
width: var(--sidebar-w);
flex-shrink: 0;
background: var(--sidebar-bg);
border-right: 1px solid var(--sidebar-border);
display: flex;
flex-direction: column;
height: 100vh;
position: fixed;
top: 0; left: 0;
z-index: 100;
overflow-y: auto;
transition: var(--transition);
}
.sidebar-brand {
padding: 24px 20px;
border-bottom: 1px solid var(--sidebar-border);
display: flex;
align-items: center;
gap: 12px;
flex-shrink: 0;
}
.brand-icon {
width: 40px; height: 40px;
background: var(--primary);
border-radius: 10px;
display: flex; align-items: center; justify-content: center;
font-size: 1.1rem;
color: white;
flex-shrink: 0;
box-shadow: var(--shadow-sm);
}
.brand-text {
display: flex;
flex-direction: column;
line-height: 1.3;
}
.brand-name {
font-size: 0.95rem;
font-weight: 700;
color: var(--text-primary);
letter-spacing: -0.01em;
}
.brand-sub {
font-size: 0.75rem;
color: var(--text-muted);
font-weight: 500;
}
.sidebar-nav {
padding: 16px 0;
flex: 1;
}
.nav-section-title {
padding: 16px 20px 8px;
font-size: 0.7rem;
font-weight: 700;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.08em;
}
.nav-item {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 20px;
color: var(--text-secondary);
font-size: 0.9rem;
font-weight: 500;
text-decoration: none;
border-radius: 0;
transition: var(--transition);
position: relative;
cursor: pointer;
border: none;
background: none;
width: 100%;
text-align: left;
}
.nav-item:hover {
background: #F3F4F6;
color: var(--text-primary);
}
.nav-item.active {
background: #EFF6FF;
color: var(--primary-dark);
}
.nav-item.active::before {
content: '';
position: absolute;
left: 0; top: 0; bottom: 0;
width: 4px;
background: var(--primary);
border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon {
width: 20px;
text-align: center;
font-size: 0.95rem;
flex-shrink: 0;
color: inherit;
}
.nav-item .nav-badge {
margin-left: auto;
background: var(--danger);
color: #fff;
font-size: 0.7rem;
font-weight: 700;
padding: 2px 8px;
border-radius: 20px;
}
.sidebar-footer {
border-top: 1px solid var(--sidebar-border);
padding: 16px;
flex-shrink: 0;
background: #FAFAFA;
}
.user-info {
display: flex;
align-items: center;
gap: 12px;
padding: 10px;
border-radius: var(--radius-md);
background: #FFFFFF;
border: 1px solid var(--sidebar-border);
box-shadow: var(--shadow-sm);
}
.user-avatar {
width: 36px; height: 36px;
border-radius: 50%;
background: #E0E7FF;
display: flex; align-items: center; justify-content: center;
font-size: 0.9rem;
font-weight: 700;
color: var(--primary-dark);
flex-shrink: 0;
}
.user-details { flex: 1; overflow: hidden; }
.user-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-muted); text-transform: capitalize; }
.user-logout {
background: none; border: none; color: var(--text-muted);
cursor: pointer; font-size: 1.1rem; padding: 6px;
transition: all 0.2s;
border-radius: var(--radius-sm);
}
.user-logout:hover { color: var(--danger); background: #FEF2F2; }
/* ══════════════════════════════
MAIN CONTENT AREA
══════════════════════════════ */
.admin-main {
margin-left: var(--sidebar-w);
flex: 1;
display: flex;
flex-direction: column;
min-height: 100vh;
min-width: 0;
}
/* ── Topbar ── */
.topbar {
height: 64px;
background: var(--bg-surface);
border-bottom: 1px solid var(--border-light);
display: flex;
align-items: center;
padding: 0 32px;
gap: 16px;
position: sticky;
top: 0;
z-index: 50;
}
.topbar-title {
font-size: 1.05rem;
font-weight: 600;
color: var(--text-primary);
flex: 1;
}
.topbar-actions {
display: flex;
align-items: center;
gap: 12px;
}
.topbar-time {
font-size: 0.82rem;
font-weight: 500;
color: var(--text-secondary);
display: flex;
align-items: center;
gap: 8px;
padding: 8px 14px;
background: #F9FAFB;
border: 1px solid var(--border-light);
border-radius: var(--radius-md);
}
/* ── Content ── */
.admin-content {
flex: 1;
padding: 32px;
overflow-y: auto;
}
/* ══════════════════════════════
DASHBOARD STATS CARDS
══════════════════════════════ */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
gap: 20px;
margin-bottom: 32px;
}
.stat-card {
background: var(--bg-surface);
border: 1px solid var(--border-light);
border-radius: var(--radius-lg);
padding: 24px;
display: flex;
align-items: flex-start;
gap: 16px;
transition: var(--transition);
box-shadow: var(--shadow-sm);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border-hover); }
.stat-icon {
width: 48px; height: 48px;
border-radius: var(--radius-lg);
display: flex; align-items: center; justify-content: center;
font-size: 1.3rem;
flex-shrink: 0;
}
.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--text-primary); line-height: 1; letter-spacing: -0.02em; }
.stat-change { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; font-weight: 500; }
/* Card color variants (Flat UI style) */
.stat-card.primary .stat-icon { background: #EFF6FF; color: #2563EB; }
.stat-card.success .stat-icon { background: #ECFDF5; color: #059669; }
.stat-card.danger .stat-icon { background: #FEF2F2; color: #DC2626; }
.stat-card.warning .stat-icon { background: #FFFBEB; color: #D97706; }
.stat-card.info .stat-icon { background: #F0F9FF; color: #0284C7; }
.stat-card.violet .stat-icon { background: #F5F3FF; color: #7C3AED; }
/* ══════════════════════════════
DATA TABLE PAGE LAYOUT
══════════════════════════════ */
.page-toolbar {
display: flex;
align-items: center;
gap: 16px;
margin-bottom: 24px;
flex-wrap: wrap;
}
.page-toolbar .search-box {
flex: 1;
min-width: 250px;
max-width: 360px;
position: relative;
}
.search-box .search-icon {
position: absolute;
left: 14px; top: 50%;
transform: translateY(-50%);
color: var(--text-muted);
font-size: 0.9rem;
}
.search-box input {
width: 100%;
padding: 10px 14px 10px 38px;
background: #FFFFFF;
border: 1px solid var(--border-light);
border-radius: var(--radius-md);
color: var(--text-primary);
font-size: 0.9rem;
outline: none;
transition: var(--transition);
font-family: 'Inter', sans-serif;
box-shadow: var(--shadow-sm);
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.search-box input::placeholder { color: #9CA3AF; }
/* ══════════════════════════════
MAP PAGE IN ADMIN
══════════════════════════════ */
.admin-map-page .admin-content {
padding: 0;
display: flex;
flex-direction: column;
}
.admin-map-page .topbar {
z-index: 500;
}
#admin-map {
flex: 1;
min-height: calc(100vh - 64px);
}
.map-sidebar-floating {
position: absolute;
top: 16px; left: 16px;
z-index: 400;
width: 280px;
background: #FFFFFF;
border: 1px solid var(--border-light);
border-radius: var(--radius-lg);
padding: 16px;
box-shadow: var(--shadow-md);
}
/* ══════════════════════════════
RESPONSIVE
══════════════════════════════ */
@media (max-width: 768px) {
.sidebar { transform: translateX(-100%); }
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.admin-main { margin-left: 0; }
.stats-grid { grid-template-columns: 1fr; }
}
+215
View File
@@ -0,0 +1,215 @@
/* =========================================================
AUTH PAGE STYLES — login.php
========================================================= */
body.auth-page {
background: #F9FAFB;
min-height: 100vh;
padding: 20px;
overflow-y: auto;
}
/* ── Center Panel (Form) ── */
.auth-center {
width: 100%;
max-width: 440px;
margin: 40px auto;
display: flex;
align-items: center;
justify-content: center;
padding: 40px;
background: #FFFFFF;
border-radius: 16px;
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
border: 1px solid #E5E7EB;
}
.auth-form-wrap {
width: 100%;
}
.auth-form-title {
font-size: 1.8rem;
font-weight: 800;
color: #111827;
margin-bottom: 8px;
letter-spacing: -0.03em;
}
.auth-form-subtitle {
color: #6B7280;
font-size: 0.95rem;
margin-bottom: 32px;
}
/* Role selector */
.role-selector {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-bottom: 32px;
}
.role-card {
position: relative;
cursor: pointer;
}
.role-card input[type="radio"] {
position: absolute;
opacity: 0;
width: 0; height: 0;
}
.role-card-label {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
padding: 16px 12px;
border-radius: 12px;
border: 2px solid #E5E7EB;
background: #FFFFFF;
cursor: pointer;
transition: all 0.2s ease;
text-align: center;
}
.role-card input:checked + .role-card-label {
border-color: #2563EB;
background: #EFF6FF;
}
.role-card-label:hover {
border-color: #D1D5DB;
background: #F9FAFB;
}
.role-card input:checked + .role-card-label:hover {
border-color: #2563EB;
}
.role-card-icon {
font-size: 1.5rem;
line-height: 1;
}
.role-card-name {
font-size: 0.9rem;
font-weight: 600;
color: #111827;
}
.role-card input:checked + .role-card-label .role-card-name {
color: #1D4ED8;
}
.role-card-desc {
font-size: 0.75rem;
color: #6B7280;
}
/* Login form */
.auth-form .form-group { margin-bottom: 20px; }
.auth-form .input-with-icon {
position: relative;
}
.auth-form .input-with-icon .input-icon {
position: absolute;
left: 16px;
top: 50%;
transform: translateY(-50%);
color: #9CA3AF;
font-size: 1rem;
pointer-events: none;
}
.auth-form .input-with-icon .form-control {
padding-left: 44px;
height: 46px;
border-radius: 8px;
}
.auth-form .btn-login {
width: 100%;
padding: 14px;
font-size: 1rem;
justify-content: center;
background: #2563EB;
color: #FFFFFF;
border-radius: 8px;
margin-top: 12px;
font-weight: 600;
box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}
.auth-form .btn-login:hover {
background: #1D4ED8;
box-shadow: 0 6px 8px -1px rgba(37, 99, 235, 0.3);
}
.auth-error {
background: #FEF2F2;
border: 1px solid #FECACA;
border-radius: 8px;
padding: 12px 16px;
color: #B91C1C;
font-size: 0.9rem;
margin-bottom: 24px;
display: flex;
align-items: center;
gap: 10px;
}
.auth-hint {
margin-top: 36px;
padding-top: 24px;
border-top: 1px solid #E5E7EB;
}
.auth-hint-title {
font-size: 0.8rem;
font-weight: 700;
color: #6B7280;
text-transform: uppercase;
letter-spacing: 0.08em;
margin-bottom: 12px;
}
.auth-hint-creds {
display: flex;
flex-direction: column;
gap: 10px;
}
.auth-hint-item {
display: flex;
justify-content: space-between;
align-items: center;
background: #F9FAFB;
border: 1px solid #E5E7EB;
border-radius: 8px;
padding: 10px 14px;
font-size: 0.85rem;
}
.auth-hint-role {
font-weight: 600;
color: #374151;
}
.auth-hint-pass {
font-family: monospace;
color: #4B5563;
background: #E5E7EB;
padding: 4px 10px;
border-radius: 6px;
font-weight: 500;
}
/* Responsive */
@media (max-width: 900px) {
.auth-center { width: 100%; border-left: none; }
}
+248
View File
@@ -0,0 +1,248 @@
/* =========================================================
WEBGIS PROJECT FINAL — Design System (main.css)
========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
:root {
/* Colors - Clean Light Theme */
--primary: #2563EB; /* Professional Blue */
--primary-light: #3B82F6;
--primary-dark: #1D4ED8;
--accent: #10B981;
--danger: #EF4444;
--warning: #F59E0B;
--info: #0EA5E9;
/* Backgrounds */
--bg-base: #F9FAFB; /* Very light gray */
--bg-surface: #FFFFFF; /* Pure white */
--bg-elevated: #FFFFFF;
--bg-card: #FFFFFF;
/* Borders */
--border-light: #E5E7EB;
--border-hover: #D1D5DB;
/* Text */
--text-primary: #111827; /* Near black */
--text-secondary: #4B5563; /* Dark gray */
--text-muted: #6B7280; /* Medium gray */
/* Sidebar */
--sidebar-w: 260px;
--sidebar-bg: #FFFFFF;
--sidebar-border: #E5E7EB;
/* Misc */
--radius-sm: 4px;
--radius-md: 8px;
--radius-lg: 12px;
--radius-xl: 16px;
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
--transition: all 0.2s ease-in-out;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
font-family: 'Inter', sans-serif;
background: var(--bg-base);
color: var(--text-primary);
font-size: 14px;
line-height: 1.6;
min-height: 100vh;
-webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
/* ── Buttons ── */
.btn {
display: inline-flex; align-items: center; gap: 8px;
padding: 8px 16px; border-radius: var(--radius-md); border: 1px solid transparent;
font-size: 0.85rem; font-weight: 500; font-family: 'Inter', sans-serif;
cursor: pointer; transition: var(--transition); white-space: nowrap;
outline: none;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-success:hover { filter: brightness(0.95); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-ghost { background: transparent; border: 1px solid var(--border-light); color: var(--text-secondary); }
.btn-ghost:hover { background: #F3F4F6; color: var(--text-primary); border-color: var(--border-hover); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
/* ── Cards ── */
.card {
background: var(--bg-surface);
border: 1px solid var(--border-light);
border-radius: var(--radius-lg);
padding: 24px;
box-shadow: var(--shadow-sm);
}
/* ── Form Elements ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.form-control {
width: 100%; padding: 10px 14px; border-radius: var(--radius-md);
background: #FFFFFF; border: 1px solid var(--border-light);
color: var(--text-primary); font-size: 0.9rem; font-family: 'Inter', sans-serif;
outline: none; transition: var(--transition); box-shadow: var(--shadow-sm);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.form-control::placeholder { color: #9CA3AF; }
select.form-control {
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 12px center;
padding-right: 36px;
}
textarea.form-control { resize: vertical; min-height: 80px; }
/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: var(--radius-xl); font-size: 0.75rem; font-weight: 600; }
.badge-primary { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.badge-success { background: #ECFDF5; color: #047857; border: 1px solid #A7F3D0; }
.badge-danger { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.badge-warning { background: #FFFBEB; color: #B45309; border: 1px solid #FDE68A; }
.badge-info { background: #F0F9FF; color: #0369A1; border: 1px solid #BAE6FD; }
/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-light); background: var(--bg-surface); box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table thead th { background: #F9FAFB; padding: 14px 16px; text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; border-bottom: 1px solid var(--border-light); }
.data-table tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.15s; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #F3F4F6; }
.data-table td { padding: 14px 16px; color: var(--text-primary); vertical-align: middle; }
.data-table .actions { display: flex; gap: 6px; }
/* ── Modal ── */
.modal-overlay {
display: none; position: fixed; inset: 0; z-index: 9999;
background: rgba(17, 24, 39, 0.4); backdrop-filter: blur(2px);
align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
background: var(--bg-surface); border: 1px solid var(--border-light);
border-radius: var(--radius-lg); padding: 32px;
width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto;
box-shadow: var(--shadow-lg);
animation: modalIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-title { font-size: 1.15rem; font-weight: 700; color: var(--text-primary); }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.4rem; padding: 4px; border-radius: var(--radius-sm); transition: all 0.15s; }
.modal-close:hover { background: #F3F4F6; color: var(--text-primary); }
.modal-footer { display: flex; gap: 12px; justify-content: flex-end; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border-light); }
/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 99999; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 14px 20px; border-radius: var(--radius-md); font-size: 0.9rem; font-weight: 500; color: #fff; box-shadow: var(--shadow-md); animation: toastIn 0.3s ease; transition: opacity 0.3s; }
.toast.success { background: #10B981; }
.toast.error { background: #EF4444; }
.toast.info { background: #3B82F6; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
/* SPBU realtime snackbar */
.spbu-snackbar {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 99998;
display: grid;
grid-template-columns: 38px minmax(0, 1fr) auto;
align-items: center;
gap: 12px;
width: min(360px, calc(100vw - 32px));
padding: 13px 14px;
color: var(--text-primary);
background: #FFFFFF;
border: 1px solid #A7F3D0;
border-left: 4px solid var(--accent);
border-radius: var(--radius-md);
box-shadow: var(--shadow-lg);
opacity: 0;
pointer-events: none;
transform: translateY(18px);
transition: opacity 0.25s ease, transform 0.25s ease;
}
.spbu-snackbar.show {
opacity: 1;
pointer-events: auto;
transform: translateY(0);
}
.spbu-snackbar-icon {
width: 38px;
height: 38px;
display: grid;
place-items: center;
color: #047857;
background: #ECFDF5;
border: 1px solid #A7F3D0;
border-radius: var(--radius-md);
}
.spbu-snackbar-title {
font-size: 0.84rem;
font-weight: 800;
line-height: 1.2;
}
.spbu-snackbar-meta {
margin-top: 3px;
color: var(--text-muted);
font-size: 0.72rem;
line-height: 1.3;
}
.spbu-snackbar-count {
min-width: 44px;
padding: 5px 8px;
color: #047857;
background: #ECFDF5;
border: 1px solid #A7F3D0;
border-radius: var(--radius-md);
text-align: center;
font-size: 1.05rem;
font-weight: 800;
}
/* ── Page header ── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.page-header p { color: var(--text-secondary); margin-top: 6px; font-size: 0.9rem; }
.page-header .breadcrumb { display: flex; gap: 8px; align-items: center; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 12px; }
.page-header .breadcrumb .sep { color: #D1D5DB; }
/* ── Utilities ── */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.w-full { width: 100%; }
+765
View File
@@ -0,0 +1,765 @@
/* =========================================================
MAP STYLES - interactive map panels and Leaflet overrides
========================================================= */
.map-page {
height: 100vh;
overflow: hidden;
background: var(--bg-base);
}
.map-wrap {
position: relative;
width: 100%;
height: calc(100vh - 64px);
background: #E5E7EB;
}
#admin-map,
#user-map {
width: 100%;
height: 100%;
background: #E5E7EB;
}
.leaflet-container {
font-family: 'Inter', sans-serif;
background: #E5E7EB;
}
.leaflet-control-attribution {
background: rgba(255, 255, 255, 0.92) !important;
color: var(--text-muted) !important;
border: 1px solid var(--border-light);
border-radius: var(--radius-sm);
box-shadow: var(--shadow-sm);
padding: 3px 8px;
font-size: 0.68rem;
}
.leaflet-control-attribution a {
color: var(--primary-dark) !important;
}
.leaflet-bar {
border: 1px solid var(--border-light) !important;
border-radius: var(--radius-md) !important;
box-shadow: var(--shadow-md) !important;
overflow: hidden;
}
.leaflet-control-zoom a,
.leaflet-draw-toolbar a {
width: 34px !important;
height: 34px !important;
line-height: 34px !important;
background: #FFFFFF !important;
color: var(--text-primary) !important;
border: 0 !important;
border-bottom: 1px solid var(--border-light) !important;
}
.leaflet-control-zoom a:last-child,
.leaflet-draw-toolbar a:last-child {
border-bottom: 0 !important;
}
.leaflet-control-zoom a:hover,
.leaflet-draw-toolbar a:hover {
background: #F3F4F6 !important;
color: var(--primary-dark) !important;
}
/* Layer panel */
.map-sidebar {
position: absolute;
top: 16px;
left: 16px;
z-index: 500;
width: 316px;
max-height: calc(100vh - 112px);
overflow-y: auto;
background: rgba(255, 255, 255, 0.96);
border: 1px solid var(--border-light);
border-radius: var(--radius-lg);
padding: 16px;
box-shadow: var(--shadow-lg);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.map-panel-header {
display: flex;
align-items: center;
gap: 12px;
padding-bottom: 14px;
margin-bottom: 14px;
border-bottom: 1px solid var(--border-light);
}
.map-panel-icon {
width: 40px;
height: 40px;
display: grid;
place-items: center;
flex-shrink: 0;
border-radius: var(--radius-md);
background: #EFF6FF;
color: var(--primary-dark);
border: 1px solid #BFDBFE;
}
.map-panel-header h3 {
margin: 0;
color: var(--text-primary);
font-size: 0.98rem;
line-height: 1.2;
font-weight: 700;
}
.map-panel-header p {
margin: 3px 0 0;
color: var(--text-muted);
font-size: 0.76rem;
line-height: 1.35;
}
.layer-section {
margin-bottom: 16px;
}
.layer-section:last-of-type {
margin-bottom: 12px;
}
.layer-section-title {
margin: 0 0 8px;
color: var(--text-muted);
font-size: 0.68rem;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.layer-item {
display: grid;
grid-template-columns: 18px 30px minmax(0, 1fr);
align-items: center;
gap: 10px;
min-height: 48px;
padding: 8px 10px;
border: 1px solid transparent;
border-radius: var(--radius-md);
color: var(--text-secondary);
cursor: pointer;
user-select: none;
transition: var(--transition);
}
.layer-item + .layer-item {
margin-top: 4px;
}
.layer-item:hover {
background: #F9FAFB;
border-color: var(--border-light);
color: var(--text-primary);
}
.layer-item input[type="checkbox"] {
width: 16px;
height: 16px;
margin: 0;
accent-color: var(--primary);
cursor: pointer;
}
.layer-color {
--layer-color: var(--primary);
width: 30px;
height: 30px;
display: grid;
place-items: center;
flex-shrink: 0;
color: #FFFFFF;
background: var(--layer-color);
border: 1px solid color-mix(in srgb, var(--layer-color) 72%, #000 28%);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.layer-color i {
font-size: 0.76rem;
}
.layer-point {
border-radius: 50%;
}
.layer-line {
height: 4px;
border-radius: 999px;
align-self: center;
box-shadow: none;
}
.layer-area {
border-radius: 6px;
background: color-mix(in srgb, var(--layer-color) 22%, #FFFFFF 78%);
border-color: var(--layer-color);
}
.layer-hatch {
background:
repeating-linear-gradient(45deg, color-mix(in srgb, var(--layer-color) 78%, #FFFFFF 22%) 0 4px, transparent 4px 8px),
color-mix(in srgb, var(--layer-color) 12%, #FFFFFF 88%);
}
.layer-gradient {
border-radius: 6px;
background: linear-gradient(90deg, #10B981 0%, #F59E0B 50%, #EF4444 100%);
border-color: #D1D5DB;
}
.layer-text {
display: flex;
flex-direction: column;
min-width: 0;
line-height: 1.25;
}
.layer-name {
color: var(--text-primary);
font-size: 0.86rem;
font-weight: 700;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.layer-meta {
margin-top: 2px;
color: var(--text-muted);
font-size: 0.7rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.map-quickstats {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
padding-top: 14px;
border-top: 1px solid var(--border-light);
}
.qs-item {
min-width: 0;
padding: 9px 6px;
text-align: center;
background: #F9FAFB;
border: 1px solid var(--border-light);
border-radius: var(--radius-md);
}
.qs-value {
font-size: 1.08rem;
line-height: 1;
font-weight: 800;
}
.qs-label {
margin-top: 3px;
color: var(--text-muted);
font-size: 0.62rem;
font-weight: 700;
}
/* Toolbar */
.map-analysis {
position: absolute;
top: 16px;
left: 50%;
z-index: 500;
display: flex;
align-items: center;
gap: 6px;
max-width: calc(100% - 380px);
padding: 8px;
background: rgba(255, 255, 255, 0.96);
border: 1px solid var(--border-light);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-md);
transform: translateX(-50%);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.map-analysis button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 7px;
min-height: 34px;
padding: 7px 12px;
color: var(--text-secondary);
background: #FFFFFF;
border: 1px solid var(--border-light);
border-radius: var(--radius-md);
font-family: 'Inter', sans-serif;
font-size: 0.78rem;
font-weight: 700;
cursor: pointer;
white-space: nowrap;
box-shadow: var(--shadow-sm);
transition: var(--transition);
}
.map-analysis button:hover {
background: #F3F4F6;
color: var(--text-primary);
border-color: var(--border-hover);
}
.map-analysis button.active {
color: #FFFFFF;
background: var(--primary);
border-color: var(--primary);
}
.map-analysis .map-tool-accent {
color: #047857;
background: #ECFDF5;
border-color: #A7F3D0;
}
.map-analysis .map-tool-accent:hover {
color: #065F46;
background: #D1FAE5;
border-color: #6EE7B7;
}
/* Nearest SPBU panel */
.spbu-panel {
position: absolute;
top: 16px;
right: 16px;
z-index: 500;
width: 310px;
padding: 16px;
background: rgba(255, 255, 255, 0.96);
border: 1px solid var(--border-light);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-lg);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.spbu-panel-title {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
color: var(--text-primary);
font-size: 0.94rem;
font-weight: 800;
}
.spbu-result {
margin-top: 10px;
padding: 12px;
background: #F9FAFB;
border: 1px solid var(--border-light);
border-radius: var(--radius-md);
}
.spbu-result-name {
color: var(--text-primary);
font-size: 0.9rem;
font-weight: 800;
}
.spbu-result-meta {
margin-top: 4px;
color: var(--text-muted);
font-size: 0.75rem;
}
.spbu-result-distance {
margin-top: 8px;
color: var(--primary-dark);
font-size: 1.35rem;
line-height: 1;
font-weight: 800;
}
/* Markers */
.marker-pin {
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
color: #FFFFFF;
background: var(--primary);
border: 2px solid #FFFFFF;
border-radius: 50% 50% 50% 0;
box-shadow: 0 6px 12px rgba(17, 24, 39, 0.28);
font-size: 0.9rem;
transform: rotate(-45deg);
}
.marker-pin > * {
transform: rotate(45deg);
}
.div-icon-wrap {
background: transparent;
border: none;
}
/* Popups */
.leaflet-popup-content-wrapper {
color: var(--text-primary) !important;
background: #FFFFFF !important;
border: 1px solid var(--border-light);
border-radius: var(--radius-lg) !important;
box-shadow: var(--shadow-lg);
}
.leaflet-popup-tip {
background: #FFFFFF !important;
}
.leaflet-popup-content {
margin: 13px 16px !important;
font-family: 'Inter', sans-serif;
font-size: 0.85rem;
line-height: 1.5;
}
.popup-title {
margin-bottom: 6px;
color: var(--text-primary);
font-size: 0.98rem;
font-weight: 800;
}
.popup-row {
display: flex;
justify-content: space-between;
gap: 12px;
margin-top: 5px;
color: var(--text-secondary);
}
.popup-row strong {
color: var(--text-primary);
}
.popup-actions {
display: flex;
gap: 8px;
margin-top: 12px;
}
.popup-actions .btn {
padding: 5px 10px;
font-size: 0.75rem;
}
/* Legend */
.map-legend {
position: absolute;
right: 16px;
bottom: 16px;
z-index: 500;
min-width: 230px;
padding: 14px;
color: var(--text-secondary);
background: rgba(255, 255, 255, 0.96);
border: 1px solid var(--border-light);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-lg);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.map-legend-title {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
color: var(--text-primary);
font-size: 0.82rem;
font-weight: 800;
}
.legend-grid {
display: grid;
gap: 7px;
}
.legend-item {
display: grid;
grid-template-columns: 24px minmax(0, 1fr);
align-items: center;
gap: 8px;
min-height: 22px;
color: var(--text-secondary);
font-size: 0.76rem;
font-weight: 600;
}
.legend-symbol {
--legend-color: var(--primary);
justify-self: center;
background: var(--legend-color);
}
.legend-dot {
width: 12px;
height: 12px;
border: 2px solid #FFFFFF;
border-radius: 50%;
box-shadow: 0 0 0 1px color-mix(in srgb, var(--legend-color) 70%, #000 30%);
}
.legend-line {
width: 22px;
height: 4px;
border-radius: 999px;
}
.legend-area {
width: 16px;
height: 16px;
border: 1px solid var(--legend-color);
border-radius: 4px;
background: color-mix(in srgb, var(--legend-color) 18%, #FFFFFF 82%);
}
.legend-hatch {
width: 16px;
height: 16px;
border: 1px solid var(--legend-color);
border-radius: 4px;
background:
repeating-linear-gradient(45deg, color-mix(in srgb, var(--legend-color) 76%, #FFFFFF 24%) 0 3px, transparent 3px 6px),
color-mix(in srgb, var(--legend-color) 12%, #FFFFFF 88%);
}
/* Modal */
.map-modal {
position: fixed;
inset: 0;
z-index: 9999;
display: none;
align-items: center;
justify-content: center;
background: rgba(17, 24, 39, 0.45);
backdrop-filter: blur(2px);
}
.map-modal.active {
display: flex;
}
.map-modal-content {
width: 90%;
max-width: 500px;
max-height: 90vh;
overflow-y: auto;
padding: 28px 32px;
background: var(--bg-surface);
border: 1px solid var(--border-light);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-lg);
animation: modalIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalIn {
from {
opacity: 0;
transform: scale(0.95) translateY(10px);
}
to {
opacity: 1;
transform: scale(1) translateY(0);
}
}
/* Loading and toast */
.map-loading {
position: absolute;
inset: 0;
z-index: 600;
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
color: var(--text-primary);
background: rgba(249, 250, 251, 0.72);
backdrop-filter: blur(3px);
font-size: 0.95rem;
font-weight: 700;
}
.spinner {
width: 28px;
height: 28px;
border: 3px solid rgba(37, 99, 235, 0.16);
border-top-color: var(--primary);
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.toast-container {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 99999;
display: flex;
flex-direction: column;
gap: 10px;
}
.toast {
max-width: 320px;
padding: 12px 20px;
color: #FFFFFF;
border-radius: var(--radius-md);
box-shadow: var(--shadow-md);
font-size: 0.88rem;
font-weight: 600;
animation: toastIn 0.3s ease;
transition: opacity 0.3s;
}
.toast.success { background: #10B981; }
.toast.error { background: #EF4444; }
.toast.info { background: #3B82F6; }
@keyframes toastIn {
from {
opacity: 0;
transform: translateX(30px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
.read-only-badge {
position: absolute;
top: 16px;
right: 16px;
z-index: 500;
display: flex;
align-items: center;
gap: 7px;
padding: 8px 13px;
color: #047857;
background: #ECFDF5;
border: 1px solid #A7F3D0;
border-radius: var(--radius-md);
box-shadow: var(--shadow-md);
font-size: 0.78rem;
font-weight: 800;
}
/* Responsive */
@media (max-width: 1180px) {
.map-analysis {
left: auto;
right: 16px;
max-width: calc(100% - 364px);
overflow-x: auto;
transform: none;
}
}
@media (max-width: 900px) {
.map-sidebar {
width: 300px;
}
.map-analysis {
top: auto;
right: 16px;
bottom: 16px;
left: 16px;
max-width: none;
justify-content: flex-start;
}
.map-legend {
right: 16px;
bottom: 78px;
}
}
@media (max-width: 768px) {
.map-wrap {
height: calc(100vh - 64px);
}
.map-sidebar {
top: 8px;
left: 8px;
width: calc(100% - 16px);
max-height: 46vh;
padding: 12px;
}
.map-panel-header {
margin-bottom: 10px;
padding-bottom: 10px;
}
.layer-item {
min-height: 44px;
}
.map-quickstats {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
.map-analysis {
right: 8px;
bottom: 8px;
left: 8px;
padding: 6px;
overflow-x: auto;
}
.map-analysis button {
min-height: 32px;
padding: 6px 10px;
font-size: 0.74rem;
}
.spbu-panel {
display: none;
}
.map-legend {
right: 8px;
bottom: 66px;
min-width: 210px;
max-width: calc(100% - 16px);
}
.read-only-badge {
top: auto;
right: 8px;
bottom: 66px;
}
}
+141
View File
@@ -0,0 +1,141 @@
/* =========================================================
public-map.js — Peta Publik SKPL
Choropleth (KF-06) + Heatmap (KF-08) + Layer switcher (KF-09)
+ Legenda + Pencarian wilayah (KF-11).
`map` & `APP_BASE` disediakan global oleh peta_publik.php.
========================================================= */
(function () {
const API = APP_BASE + '/api';
let choroplethLayer = null;
let heatLayer = null;
let wilayahFeatures = [];
// ---- Skala warna persentase kemiskinan ----
function colorFor(persen) {
return persen >= 10 ? '#EF4444' // merah — tinggi
: persen >= 5 ? '#FB923C' // oranye — sedang-tinggi
: persen >= 2 ? '#FBBF24' // kuning — sedang
: persen > 0 ? '#A3E635' // hijau muda — rendah
: '#2ECC71'; // hijau — tanpa kasus
}
function styleWilayah(feature) {
const p = feature.properties.persentase_miskin || 0;
return {
fillColor: colorFor(p),
fillOpacity: 0.55,
color: '#374151',
weight: 1.5,
};
}
function popupWilayah(props) {
return `<div style="font-weight:700;margin-bottom:6px;">${props.nama}</div>
<div style="font-size:0.85rem;line-height:1.6;">
Penduduk: <strong>${props.jumlah_penduduk}</strong><br>
Warga miskin: <strong>${props.jumlah_miskin}</strong><br>
Persentase: <strong>${props.persentase_miskin}%</strong>
</div>`;
}
// ---- Choropleth (KF-06) ----
async function loadChoropleth() {
const r = await fetch(`${API}/wilayah.php`);
const j = await r.json();
const data = j.status === 'success' ? j.data : { type: 'FeatureCollection', features: [] };
wilayahFeatures = data.features || [];
choroplethLayer = L.geoJSON(data, {
style: styleWilayah,
onEachFeature: (f, layer) => {
layer.bindPopup(popupWilayah(f.properties));
layer.bindTooltip(f.properties.nama, { sticky: true });
},
}).addTo(map);
if (wilayahFeatures.length) {
map.fitBounds(choroplethLayer.getBounds(), { padding: [40, 40] });
}
return choroplethLayer;
}
// ---- Heatmap (KF-08) ----
async function loadHeatmap() {
const r = await fetch(`${API}/heatmap.php`);
const j = await r.json();
const points = j.status === 'success' ? j.data : [];
heatLayer = L.heatLayer(points, {
radius: 30, blur: 22, maxZoom: 17,
gradient: { 0.2: '#3B82F6', 0.5: '#FBBF24', 0.9: '#EF4444' },
});
return heatLayer;
}
// ---- Legenda (KF-06) ----
function addLegend() {
const legend = L.control({ position: 'bottomleft' });
legend.onAdd = function () {
const div = L.DomUtil.create('div', 'legend');
const grades = [
{ c: '#2ECC71', t: 'Tidak ada kasus' },
{ c: '#A3E635', t: '< 2% miskin' },
{ c: '#FBBF24', t: '2 5%' },
{ c: '#FB923C', t: '5 10%' },
{ c: '#EF4444', t: '> 10% (prioritas)' },
];
div.innerHTML = '<h4>Tingkat Kemiskinan</h4>' +
grades.map(g => `<div><i style="background:${g.c}"></i>${g.t}</div>`).join('');
return div;
};
legend.addTo(map);
}
// ---- Pencarian wilayah (KF-11) ----
function addSearch() {
const ctrl = L.control({ position: 'topright' });
ctrl.onAdd = function () {
const div = L.DomUtil.create('div', 'map-search');
div.innerHTML = `<input type="text" id="searchWilayah" placeholder="🔍 Cari kelurahan..." autocomplete="off">
<div id="searchResults" class="search-results"></div>`;
L.DomEvent.disableClickPropagation(div);
return div;
};
ctrl.addTo(map);
const input = document.getElementById('searchWilayah');
const results = document.getElementById('searchResults');
input.addEventListener('input', function () {
const q = this.value.toLowerCase().trim();
results.innerHTML = '';
if (!q) return;
wilayahFeatures
.filter(f => f.properties.nama.toLowerCase().includes(q))
.slice(0, 6)
.forEach(f => {
const item = document.createElement('div');
item.className = 'search-item';
item.textContent = f.properties.nama;
item.onclick = () => {
const layer = L.geoJSON(f);
map.fitBounds(layer.getBounds(), { padding: [60, 60] });
results.innerHTML = '';
input.value = f.properties.nama;
};
results.appendChild(item);
});
});
}
// ---- Inisialisasi ----
Promise.all([loadChoropleth(), loadHeatmap()]).then(([choro, heat]) => {
// Layer switcher (KF-09)
L.control.layers(null, {
'Batas Kelurahan (Choropleth)': choro,
'Heatmap Kepadatan': heat,
}, { collapsed: false, position: 'topright' }).addTo(map);
addLegend();
addSearch();
});
})();
+127
View File
@@ -0,0 +1,127 @@
/* =========================================================
skpl-layers.js — Layer SKPL reusable untuk peta login.
Choropleth kelurahan (KF-06) + Heatmap (KF-08) + legenda +
layer switcher overlay (KF-09) + pencarian wilayah (KF-11).
Pakai: panggil attachSkplLayers(map) setelah map dibuat.
Butuh leaflet.heat sudah dimuat di halaman.
========================================================= */
(function () {
function injectStyle() {
if (document.getElementById('skpl-layer-style')) return;
const css = `
.skpl-legend{background:#fff;padding:10px 12px;border-radius:10px;box-shadow:0 2px 10px rgba(0,0,0,.15);font-size:.76rem;line-height:1.6}
.skpl-legend h4{font-size:.78rem;margin:0 0 6px}
.skpl-legend i{display:inline-block;width:13px;height:13px;border-radius:3px;margin-right:6px;vertical-align:middle}
.skpl-search{background:#fff;border-radius:10px;box-shadow:0 2px 10px rgba(0,0,0,.15);padding:6px;width:220px}
.skpl-search input{width:100%;border:1px solid #E5E7EB;border-radius:7px;padding:7px 9px;font-size:.83rem;outline:none}
.skpl-search input:focus{border-color:#2563EB}
.skpl-results .item{padding:7px 9px;font-size:.82rem;cursor:pointer;border-radius:6px}
.skpl-results .item:hover{background:#EFF6FF;color:#1D4ED8}`;
const s = document.createElement('style');
s.id = 'skpl-layer-style';
s.textContent = css;
document.head.appendChild(s);
}
function colorFor(p) {
return p >= 10 ? '#EF4444' : p >= 5 ? '#FB923C' : p >= 2 ? '#FBBF24' : p > 0 ? '#A3E635' : '#2ECC71';
}
window.attachSkplLayers = async function (map) {
if (!map || typeof L === 'undefined') return;
injectStyle();
const API = (typeof APP_BASE !== 'undefined' ? APP_BASE : '') + '/api';
let features = [];
// Choropleth
let choro = null;
try {
const j = await (await fetch(`${API}/wilayah.php`)).json();
const data = j.status === 'success' ? j.data : { type: 'FeatureCollection', features: [] };
features = data.features || [];
choro = L.geoJSON(data, {
style: f => ({
fillColor: colorFor(f.properties.persentase_miskin || 0),
fillOpacity: 0.5, color: '#374151', weight: 1.5,
}),
onEachFeature: (f, layer) => {
const p = f.properties;
layer.bindPopup(`<div style="font-weight:700;margin-bottom:6px;">${p.nama}</div>
<div style="font-size:.85rem;line-height:1.6;">
Penduduk: <strong>${p.jumlah_penduduk}</strong><br>
Warga miskin: <strong>${p.jumlah_miskin}</strong><br>
Persentase: <strong>${p.persentase_miskin}%</strong></div>`);
layer.bindTooltip(p.nama, { sticky: true });
},
});
} catch (e) { /* abaikan */ }
// Heatmap
let heat = null;
try {
const j = await (await fetch(`${API}/heatmap.php`)).json();
const pts = j.status === 'success' ? j.data : [];
if (L.heatLayer) {
heat = L.heatLayer(pts, {
radius: 30, blur: 22, maxZoom: 17,
gradient: { 0.2: '#3B82F6', 0.5: '#FBBF24', 0.9: '#EF4444' },
});
}
} catch (e) { /* abaikan */ }
// Layer switcher overlay
const overlays = {};
if (choro) overlays['🗺️ Choropleth Kelurahan'] = choro;
if (heat) overlays['🔥 Heatmap Kepadatan'] = heat;
if (Object.keys(overlays).length) {
L.control.layers(null, overlays, { collapsed: true, position: 'topright' }).addTo(map);
}
// Legenda
const legend = L.control({ position: 'bottomleft' });
legend.onAdd = function () {
const div = L.DomUtil.create('div', 'skpl-legend');
const g = [
['#2ECC71', 'Tidak ada kasus'], ['#A3E635', '< 2%'],
['#FBBF24', '2 5%'], ['#FB923C', '5 10%'], ['#EF4444', '> 10% (prioritas)'],
];
div.innerHTML = '<h4>Tingkat Kemiskinan</h4>' +
g.map(x => `<div><i style="background:${x[0]}"></i>${x[1]}</div>`).join('');
return div;
};
legend.addTo(map);
// Pencarian wilayah (KF-11)
const search = L.control({ position: 'topright' });
search.onAdd = function () {
const div = L.DomUtil.create('div', 'skpl-search');
div.innerHTML = `<input type="text" placeholder="🔍 Cari kelurahan...">
<div class="skpl-results"></div>`;
L.DomEvent.disableClickPropagation(div);
return div;
};
search.addTo(map);
const root = document.querySelector('.skpl-search');
if (root) {
const input = root.querySelector('input');
const res = root.querySelector('.skpl-results');
input.addEventListener('input', function () {
const q = this.value.toLowerCase().trim();
res.innerHTML = '';
if (!q) return;
features.filter(f => f.properties.nama.toLowerCase().includes(q)).slice(0, 6).forEach(f => {
const it = document.createElement('div');
it.className = 'item';
it.textContent = f.properties.nama;
it.onclick = () => {
map.fitBounds(L.geoJSON(f).getBounds(), { padding: [60, 60] });
res.innerHTML = '';
input.value = f.properties.nama;
};
res.appendChild(it);
});
});
}
};
})();
+75
View File
@@ -0,0 +1,75 @@
/* =========================================================
skpl-map.js — Peta SKPL (operator & pimpinan)
Warga miskin (POI) + fasilitas publik + choropleth + heatmap
(choropleth/heatmap/legenda/pencarian via attachSkplLayers).
Role ditentukan global SKPL_ROLE ('operator' | 'pimpinan').
========================================================= */
(function () {
const API = APP_BASE + '/api';
const ROLE = (typeof SKPL_ROLE !== 'undefined') ? SKPL_ROLE : 'pimpinan';
let map, wargaLayer, fasilitasLayer;
const FAS_ICON = { sekolah: '🏫', puskesmas: '🏥', pasar: '🏪', kantor_kelurahan: '🏛️', rumah_ibadah: '🕌', lainnya: '📍' };
function divIcon(emoji, bg, size = 30) {
return L.divIcon({
className: 'div-icon-wrap',
html: `<div style="background:${bg};width:${size}px;height:${size}px;border-radius:50% 50% 50% 0;transform:rotate(-45deg);display:flex;align-items:center;justify-content:center;box-shadow:0 2px 5px rgba(0,0,0,.3);border:2px solid #fff;"><span style="transform:rotate(45deg);font-size:${size*0.45}px;">${emoji}</span></div>`,
iconSize: [size, size], iconAnchor: [size / 2, size], popupAnchor: [0, -size],
});
}
const wargaIcon = divIcon('👤', '#EF4444');
function wargaPopup(p) {
const vb = { terverifikasi: '#10B981', perlu_tinjauan: '#F59E0B', belum: '#9CA3AF' }[p.status_verifikasi] || '#9CA3AF';
let h = `<div style="min-width:200px;"><div style="font-weight:700;margin-bottom:4px;">${p.nama_kk}</div>`;
if (p.nik_kk) h += `<div style="font-size:.8rem;">NIK: ${p.nik_kk}</div>`;
if (p.alamat) h += `<div style="font-size:.8rem;">${p.alamat}</div>`;
h += `<div style="font-size:.8rem;">Penghasilan: Rp ${Number(p.penghasilan||0).toLocaleString('id-ID')}</div>`;
h += `<div style="font-size:.8rem;">Jiwa: ${p.jumlah_jiwa||'-'} · Tanggungan: ${p.jumlah_tanggungan||0}</div>`;
h += `<div style="font-size:.8rem;">Air: ${p.sumber_air||'-'} · Dinding: ${p.material_dinding||'-'}</div>`;
h += `<div style="font-size:.8rem;">Bantuan: <b>${p.bantuan_aktif||'Belum ada'}</b></div>`;
h += `<div style="font-size:.8rem;">Status: <b style="color:${vb}">${p.status_verifikasi||'belum'}</b>${p.jumlah_foto?' · 📷 '+p.jumlah_foto:''}</div>`;
if (ROLE === 'operator') {
h += `<div style="display:flex;gap:6px;margin-top:8px;">
<button onclick="window.location.href='${APP_BASE}/admin/data_warga.php'" style="flex:1;padding:6px;border:1px solid #2563EB;background:#2563EB;color:#fff;border-radius:6px;cursor:pointer;font-size:.78rem;">Kelola</button>
<button onclick="SKPLMAP_del(${p.id})" style="padding:6px 10px;border:1px solid #EF4444;background:#fff;color:#EF4444;border-radius:6px;cursor:pointer;font-size:.78rem;">Hapus</button>
</div>`;
}
return h + `</div>`;
}
async function loadWarga() {
const j = await (await fetch(`${API}/warga_miskin.php`)).json();
const data = j.status === 'success' ? j.data : { features: [] };
wargaLayer = L.geoJSON(data, {
pointToLayer: (f, ll) => L.marker(ll, { icon: wargaIcon }),
onEachFeature: (f, l) => l.bindPopup(wargaPopup(f.properties)),
}).addTo(map);
}
async function loadFasilitas() {
const j = await (await fetch(`${API}/fasilitas.php`)).json();
const data = j.status === 'success' ? j.data : { features: [] };
fasilitasLayer = L.geoJSON(data, {
pointToLayer: (f, ll) => L.marker(ll, { icon: divIcon(FAS_ICON[f.properties.jenis] || '📍', '#2563EB', 26) }),
onEachFeature: (f, l) => l.bindPopup(`<b>${f.properties.nama}</b><br><span style="font-size:.8rem;color:#6B7280;">${f.properties.jenis.replace('_',' ')}</span>`),
});
}
window.SKPLMAP_del = async function (id) {
if (!confirm('Hapus data warga ini?')) return;
const r = await (await fetch(`${API}/warga_miskin.php?id=${id}`, { method: 'DELETE' })).json();
if (r.status === 'success') { map.removeLayer(wargaLayer); loadWarga(); }
else alert(r.message || 'Gagal');
};
document.addEventListener('DOMContentLoaded', async () => {
map = L.map('skpl-map').setView([-0.0500, 109.3450], 13);
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', { subdomains: 'abcd', maxZoom: 19, attribution: '© OpenStreetMap, © CARTO' }).addTo(map);
await loadWarga();
await loadFasilitas();
if (window.attachSkplLayers) await window.attachSkplLayers(map);
// tambahkan toggle warga & fasilitas
L.control.layers(null, { '👤 Warga Miskin': wargaLayer, '🏢 Fasilitas Publik': fasilitasLayer }, { collapsed: true, position: 'topright' }).addTo(map);
});
})();