feat: display custom marker icons on parent map

API now returns iconUrl and iconSize for each marker, allowing custom
marker icons defined in marker.yml to be displayed on the map-editor
field of the parent map page.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-02-06 08:28:49 +01:00
parent 68d3142126
commit 575534d182
3 changed files with 629 additions and 20595 deletions

View file

@ -55,6 +55,15 @@ return [
// Format markers for response // Format markers for response
$markers = []; $markers = [];
foreach ($markerPages as $marker) { foreach ($markerPages as $marker) {
// Get custom icon if available
$iconFile = $marker->markerIcon()->toFile();
$iconUrl = $iconFile ? $iconFile->url() : null;
// Get icon size if set
$iconSize = $marker->markerIconSize()->isNotEmpty()
? (int) $marker->markerIconSize()->value()
: 40;
$markers[] = [ $markers[] = [
'id' => $marker->id(), 'id' => $marker->id(),
'slug' => $marker->slug(), 'slug' => $marker->slug(),
@ -64,7 +73,9 @@ return [
'lon' => (float) $marker->longitude()->value() 'lon' => (float) $marker->longitude()->value()
], ],
'num' => $marker->num(), 'num' => $marker->num(),
'panelUrl' => (string) $marker->panel()->url() 'panelUrl' => (string) $marker->panel()->url(),
'iconUrl' => $iconUrl,
'iconSize' => $iconSize
]; ];
} }
@ -173,6 +184,13 @@ return [
// Publish the page as listed with the correct num // Publish the page as listed with the correct num
$newMarker->changeStatus('listed', $nextNum); $newMarker->changeStatus('listed', $nextNum);
// Get custom icon if available (new markers won't have one initially)
$iconFile = $newMarker->markerIcon()->toFile();
$iconUrl = $iconFile ? $iconFile->url() : null;
$iconSize = $newMarker->markerIconSize()->isNotEmpty()
? (int) $newMarker->markerIconSize()->value()
: 40;
return [ return [
'status' => 'success', 'status' => 'success',
'data' => [ 'data' => [
@ -185,7 +203,9 @@ return [
'lon' => $lon 'lon' => $lon
], ],
'num' => $nextNum, 'num' => $nextNum,
'panelUrl' => (string) $newMarker->panel()->url() 'panelUrl' => (string) $newMarker->panel()->url(),
'iconUrl' => $iconUrl,
'iconSize' => $iconSize
] ]
] ]
]; ];
@ -268,6 +288,13 @@ return [
'longitude' => $lon 'longitude' => $lon
]); ]);
// Get custom icon if available
$iconFile = $marker->markerIcon()->toFile();
$iconUrl = $iconFile ? $iconFile->url() : null;
$iconSize = $marker->markerIconSize()->isNotEmpty()
? (int) $marker->markerIconSize()->value()
: 40;
return [ return [
'status' => 'success', 'status' => 'success',
'data' => [ 'data' => [
@ -280,7 +307,9 @@ return [
'lon' => $lon 'lon' => $lon
], ],
'num' => $marker->num(), 'num' => $marker->num(),
'panelUrl' => '/panel/pages/' . $marker->id() 'panelUrl' => '/panel/pages/' . $marker->id(),
'iconUrl' => $iconUrl,
'iconSize' => $iconSize
] ]
] ]
]; ];

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long