This commit is contained in:
Andras Schmelczer 2026-04-04 17:44:44 +01:00
parent b94cf17d75
commit 0c6d207967
41 changed files with 1809 additions and 1204 deletions

View file

@ -136,15 +136,26 @@ export default memo(function Map({
const container = containerRef.current;
if (!container) return;
let resizeTimer: ReturnType<typeof setTimeout> | null = null;
let initialized = false;
const observer = new ResizeObserver((entries) => {
const { width, height } = entries[0].contentRect;
if (width > 0 && height > 0) {
setDimensions({ width, height });
if (!initialized) {
initialized = true;
setDimensions({ width, height });
} else {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => setDimensions({ width, height }), 150);
}
}
});
observer.observe(container);
return () => observer.disconnect();
return () => {
observer.disconnect();
if (resizeTimer) clearTimeout(resizeTimer);
};
}, []);
useEffect(() => {
@ -209,7 +220,13 @@ export default memo(function Map({
{...viewState}
onMove={handleMove}
onLoad={undefined}
onIdle={screenshotMode ? () => { window.__map_idle = true; } : undefined}
onIdle={
screenshotMode
? () => {
window.__map_idle = true;
}
: undefined
}
mapStyle={mapStyle}
style={{ width: '100%', height: '100%' }}
attributionControl={false}
@ -222,9 +239,7 @@ export default memo(function Map({
maxBounds={MAP_BOUNDS}
>
<DeckOverlay layers={layers} getTooltip={null} />
{!screenshotMode && (
<ScaleControl position="bottom-left" maxWidth={100} unit="metric" />
)}
{!screenshotMode && <ScaleControl position="bottom-left" maxWidth={100} unit="metric" />}
</MapGL>
{screenshotMode ? (
ogMode ? (
@ -233,7 +248,10 @@ export default memo(function Map({
<div className="flex-1 flex items-center justify-center">
<div className="flex items-center gap-8 bg-navy-900/90 rounded-3xl px-14 py-10">
<LogoIcon className="w-24 h-24 text-teal-400" />
<span className="font-bold text-white whitespace-nowrap" style={{ fontSize: '5rem' }}>
<span
className="font-bold text-white whitespace-nowrap"
style={{ fontSize: '5rem' }}
>
Your perfect postcode
</span>
</div>
@ -280,7 +298,11 @@ export default memo(function Map({
(viewFeature && colorRange ? (
viewFeature.startsWith('tt_') ? (
<MapLegend
featureLabel={t('travel.travelTime', { mode: modes.label(viewFeature.split('_')[1] as 'car' | 'bicycle' | 'walking' | 'transit') })}
featureLabel={t('travel.travelTime', {
mode: modes.label(
viewFeature.split('_')[1] as 'car' | 'bicycle' | 'walking' | 'transit'
),
})}
range={colorRange}
showCancel={viewSource === 'eye'}
onCancel={onCancelPin}
@ -315,7 +337,8 @@ export default memo(function Map({
: [countRange.min, countRange.max]
}
totalCount={
totalCountProp ?? (usePostcodeView ? postcodeCountRange.total : countRange.total)
totalCountProp ??
(usePostcodeView ? postcodeCountRange.total : countRange.total)
}
showCancel={false}
onCancel={onCancelPin}