feat: implement automatic static map image generation

- Add html-to-image for capturing map container with markers
- Auto-generate map image on page/marker save via hooks
- Use flag system (.regenerate-map-image) to trigger generation on Panel reload
- Create file using Kirby API for proper indexing
- Add mapStaticImage field in blueprint to display generated image
- Wait for map to be fully loaded before capture
- Capture entire container (map + custom markers)
- Filter MapLibre controls from capture

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-02-06 11:48:05 +01:00
parent 1d74105910
commit 9193ac8900
8 changed files with 474 additions and 92 deletions

View file

@ -51,5 +51,23 @@ Kirby::plugin('geoproject/map-editor', [
],
'api' => [
'routes' => require __DIR__ . '/api/routes.php'
],
'hooks' => [
'page.update:after' => function ($newPage, $oldPage) {
// Mark map page for image regeneration
if ($newPage->intendedTemplate()->name() === 'map') {
$markerFile = $newPage->root() . '/.regenerate-map-image';
file_put_contents($markerFile, time());
}
// If a marker is updated, mark the parent map page for regeneration
if ($newPage->intendedTemplate()->name() === 'marker') {
$mapPage = $newPage->parent();
if ($mapPage && $mapPage->intendedTemplate()->name() === 'map') {
$markerFile = $mapPage->root() . '/.regenerate-map-image';
file_put_contents($markerFile, time());
}
}
}
]
]);