2026-01-28 15:43:23 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map Editor Plugin for Kirby CMS
|
|
|
|
|
*
|
|
|
|
|
* Interactive map editor with MapLibre GL JS for creating
|
|
|
|
|
* print-ready maps with markers and rich content.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Kirby::plugin('geoproject/map-editor', [
|
|
|
|
|
'fields' => [
|
|
|
|
|
'map-editor' => [
|
|
|
|
|
'props' => [
|
|
|
|
|
'defaultCenter' => function ($defaultCenter = [43.836699, 4.360054]) {
|
|
|
|
|
return $defaultCenter;
|
|
|
|
|
},
|
|
|
|
|
'defaultZoom' => function ($defaultZoom = 13) {
|
|
|
|
|
return $defaultZoom;
|
|
|
|
|
},
|
|
|
|
|
'maxMarkers' => function ($maxMarkers = 50) {
|
|
|
|
|
return $maxMarkers;
|
2026-01-29 14:08:40 +01:00
|
|
|
},
|
|
|
|
|
'mode' => function ($mode = 'multi') {
|
|
|
|
|
return $mode;
|
|
|
|
|
},
|
|
|
|
|
'latitude' => function ($latitude = null) {
|
|
|
|
|
return $latitude;
|
|
|
|
|
},
|
|
|
|
|
'longitude' => function ($longitude = null) {
|
|
|
|
|
return $longitude;
|
2026-01-29 16:14:33 +01:00
|
|
|
},
|
|
|
|
|
'markerIconUrl' => function ($markerIconUrl = null) {
|
|
|
|
|
// Auto-detect marker icon from page files
|
|
|
|
|
if ($markerIconUrl === null && $this->model()) {
|
|
|
|
|
$iconFile = $this->model()->markerIcon()->toFile();
|
|
|
|
|
if ($iconFile) {
|
|
|
|
|
return $iconFile->url();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $markerIconUrl;
|
|
|
|
|
},
|
|
|
|
|
'markerIconSize' => function ($markerIconSize = 40) {
|
|
|
|
|
// Auto-detect marker icon size from page
|
|
|
|
|
if ($this->model() && $this->model()->markerIconSize()->isNotEmpty()) {
|
|
|
|
|
return (int) $this->model()->markerIconSize()->value();
|
|
|
|
|
}
|
|
|
|
|
return $markerIconSize;
|
2026-01-28 15:43:23 +01:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
]
|
2026-01-29 14:08:40 +01:00
|
|
|
],
|
|
|
|
|
'api' => [
|
|
|
|
|
'routes' => require __DIR__ . '/api/routes.php'
|
2026-01-28 15:43:23 +01:00
|
|
|
]
|
|
|
|
|
]);
|