Project Dependencies & Setup (English)
To use theMejikDatatable, SidebarTreeCalendar, and LeafletMap components, your Vue 2 project must have the following dependencies installed and configured.
1. Core Dependencies (for All Components)
These libraries are used across multiple components for API calls, styling, and UI elements.- Axios: For making API calls to your Laravel backend.
- Bootstrap & BootstrapVue: Bootstrap provides the CSS styling, and BootstrapVue provides pre-made Vue components like the pagination controls used in
MejikDatatable.
- Line Awesome: A free icon toolkit used for the icons in the
SidebarTree...components.
2. Map-Specific Dependencies
These are required only if you are using theLeafletMap component.
- Leaflet: The core interactive map library.
- Leaflet.markercluster: For clustering point markers at lower zoom levels.
- Leaflet-draw: For the “select by drawing a rectangle” feature.
3. Setup in main.js
You must import the necessary CSS files and install the Vue plugins in your project’s entry point, typically src/main.js.
Documentation: LeafletMap Component (English)
1. Overview
LeafletMap is a highly interactive, data-driven map component built on Vue 2 and Leaflet. It’s designed for displaying and interacting with complex GeoJSON data from a backend. It supports dynamic data loading based on the map’s viewport, feature clustering, multi-layer management, and advanced feature selection via clicking or drawing.
2. Features
- GeoJSON Native: Renders any standard GeoJSON geometry (
Point,LineString,Polygon). - Viewport-Based Loading: Emits events (
@update-view) when the map is panned or zoomed, allowing the parent to fetch only the necessary data. - Layer Management: Supports toggling the visibility of different types of features (e.g., live points vs. historical tracks) via a prop.
- Marker Clustering: Automatically clusters point features at lower zoom levels for better performance and readability, using
leaflet.markercluster. - Advanced Selection:
- Supports
none,single, andmulti-select modes. - Allows selection by clicking individual features.
- Allows multi-selection by drawing a bounding box (rectangle) on the map, using
leaflet-draw. - Custom Popups: Provides a scoped slot (
#popup-content) to render fully custom Vue components inside map popups. - State Syncing: Uses the
.syncmodifier forselectedFeaturesto maintain a two-way binding with the parent component.
3. Props
4. Emitted Events
5. Scoped Slots
6. Backend Data & Laravel Controller Example
Data Format (GeoJSON)
The backend must provide a GeoJSONFeatureCollection. The properties.type field is crucial as it determines which layer the feature belongs to (e.g., 'live-position', 'movement-track').
Laravel Controller with Configurable Transformer
This example shows a controller for fetching live personnel data. It uses a reusable trait to handle the GeoJSON conversion, making the controller clean and declarative.7. Usage Example
This parent component provides UI controls for all the map’s features.Dependensi & Pengaturan Proyek (Bahasa Indonesia)
Untuk menggunakan komponenMejikDatatable, SidebarTreeCalendar, dan LeafletMap, proyek Vue 2 Anda harus memiliki dependensi berikut terinstal dan terkonfigurasi.
1. Dependensi Inti (untuk Semua Komponen)
Library ini digunakan di banyak komponen untuk panggilan API, styling, dan elemen UI.- Axios: Untuk melakukan panggilan API ke backend Laravel Anda.
- Bootstrap & BootstrapVue: Bootstrap menyediakan styling CSS, dan BootstrapVue menyediakan komponen Vue siap pakai seperti kontrol paginasi yang digunakan di
MejikDatatable.
- Line Awesome: Pustaka ikon gratis yang digunakan untuk ikon-ikon di komponen
SidebarTree....
2. Dependensi Khusus Peta (Map)
Dependensi ini hanya dibutuhkan jika Anda menggunakan komponenLeafletMap.
- Leaflet: Library inti untuk peta interaktif.
- Leaflet.markercluster: Untuk mengelompokkan (clustering) penanda titik pada level zoom rendah.
- Leaflet-draw: Untuk fitur “pilih dengan menggambar persegi panjang”.
3. Pengaturan di main.js
Anda wajib mengimpor file CSS yang diperlukan dan menginstal plugin Vue di file entri proyek Anda, biasanya di src/main.js.
Dokumentasi: Komponen LeafletMap (Bahasa Indonesia)
1. Gambaran Umum
LeafletMap adalah komponen peta berbasis data yang sangat interaktif, dibangun di atas Vue 2 dan Leaflet. Komponen ini dirancang untuk menampilkan dan berinteraksi dengan data GeoJSON yang kompleks dari backend. Mendukung pemuatan data dinamis berdasarkan viewport peta, pengelompokan (clustering) fitur, manajemen multi-layer, dan seleksi fitur tingkat lanjut melalui klik atau gambar.
2. Fitur
- Natif GeoJSON: Merender semua jenis geometri standar GeoJSON (
Point,LineString,Polygon). - Pemuatan Berbasis Viewport: Memancarkan event (
@update-view) saat peta digeser atau di-zoom, memungkinkan komponen induk untuk mengambil data yang hanya diperlukan. - Manajemen Layer: Mendukung pengalihan visibilitas berbagai jenis fitur (mis., titik live vs. jejak historis) melalui sebuah prop.
- Marker Clustering: Secara otomatis mengelompokkan fitur titik pada tingkat zoom rendah untuk performa dan keterbacaan yang lebih baik, menggunakan
leaflet.markercluster. - Seleksi Tingkat Lanjut:
- Mendukung mode seleksi
none,single, danmulti. - Memungkinkan pemilihan dengan mengklik fitur individual.
- Memungkinkan multi-seleksi dengan menggambar kotak pembatas (bounding box) di peta, menggunakan
leaflet-draw. - Popup Kustom: Menyediakan scoped slot (
#popup-content) untuk merender komponen Vue kustom di dalam popup peta. - Sinkronisasi State: Menggunakan modifier
.syncuntukselectedFeaturesuntuk menjaga binding dua arah dengan komponen induk.
3. Props
4. Event yang Di-emit
5. Scoped Slots
6. Data Backend & Contoh Controller Laravel
Format Data (GeoJSON)
Backend harus menyediakanFeatureCollection GeoJSON. Field properties.type sangat penting karena menentukan ke layer mana fitur tersebut akan dimasukkan (mis., 'live-position', 'movement-track').
Controller Laravel dengan Transformer
Contoh ini menunjukkan controller untuk mengambil data personel live. Ia menggunakantrait yang dapat digunakan kembali untuk menangani konversi GeoJSON, membuat controller menjadi bersih dan deklaratif.
7. Contoh Penggunaan
Komponen induk ini menyediakan kontrol UI untuk semua fitur peta. (Kode untukMapPage.vue sama seperti versi Bahasa Inggris, Anda hanya perlu menerjemahkan teks UI seperti “Visible Layers” menjadi “Layer yang Terlihat”, dll.)