mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-07-06 20:37:56 +02:00
fix: resolve Next.js docker build endpoints and handle async map icons
Former-commit-id: 6241ea44db
This commit is contained in:
@@ -373,15 +373,37 @@ const MaplibreViewer = ({ data, activeLayers, onEntityClick, flyToLocation, sele
|
||||
const onMapLoad = useCallback((e: any) => {
|
||||
const map = e.target;
|
||||
|
||||
// Track which images are still loading so we can retry on styleimagemissing
|
||||
const pendingImages: Record<string, string> = {};
|
||||
|
||||
const loadImg = (id: string, url: string) => {
|
||||
if (!map.hasImage(id)) {
|
||||
pendingImages[id] = url;
|
||||
const img = new Image();
|
||||
img.crossOrigin = "anonymous";
|
||||
img.src = url;
|
||||
img.onload = () => map.addImage(id, img);
|
||||
img.onload = () => {
|
||||
if (!map.hasImage(id)) map.addImage(id, img);
|
||||
delete pendingImages[id];
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// Suppress "image not found" warnings — retry when the async load finishes
|
||||
map.on('styleimagemissing', (ev: any) => {
|
||||
const id = ev.id;
|
||||
const url = pendingImages[id];
|
||||
if (url) {
|
||||
const img = new Image();
|
||||
img.crossOrigin = "anonymous";
|
||||
img.src = url;
|
||||
img.onload = () => {
|
||||
if (!map.hasImage(id)) map.addImage(id, img);
|
||||
delete pendingImages[id];
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Legacy generic plane icons (still used as fallbacks)
|
||||
loadImg('svgPlaneCyan', svgPlaneCyan);
|
||||
loadImg('svgPlaneYellow', svgPlaneYellow);
|
||||
|
||||
Reference in New Issue
Block a user