geoproject-app/public/site/plugins/map-editor/index.php
isUnknown b19635f324 feat: add custom marker icons with configurable size
- Add markerIcon files field to marker.yml for custom JPG/PNG/SVG icons
- Add markerIconSize range field (20-500px, default 40px) with unit display
- Layout icon fields side-by-side (50/50 width) in marker blueprint
- Add markerIconUrl prop in index.php to auto-detect uploaded icon
- Add markerIconSize prop in index.php to read size from page data
- Update MapPreview.vue to display custom images instead of default pins
- Set icon dimensions dynamically based on markerIconSize value
- Icon size updates on save/reload (reactive implementation deferred)
- Remove custom tiles background functionality (not needed)

Note: Custom icons show uploaded image, may have white background on
transparent PNGs depending on image processing. Size is non-reactive
and requires save + reload to update in preview.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-29 16:14:33 +01:00

55 lines
1.9 KiB
PHP

<?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;
},
'mode' => function ($mode = 'multi') {
return $mode;
},
'latitude' => function ($latitude = null) {
return $latitude;
},
'longitude' => function ($longitude = null) {
return $longitude;
},
'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;
}
]
]
],
'api' => [
'routes' => require __DIR__ . '/api/routes.php'
]
]);