Skip to content

Commit a3ba809

Browse files
committed
bottom bar
1 parent 4818616 commit a3ba809

File tree

2 files changed

+87
-39
lines changed

2 files changed

+87
-39
lines changed

src/app/components/Map/index.tsx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ const Map = (props: MapProps) => {
221221
zoom={defaultZoom}
222222
maxZoom={19}
223223
zoomControl={false}
224+
hash={true}
224225
// @ts-ignore
225226
timeDimensionControl={true}
226227
timeDimensionextendedControl={true}
@@ -255,27 +256,35 @@ const Map = (props: MapProps) => {
255256
>
256257
<ScaleControl imperial={false} />
257258

258-
<ZoomControl position={'topright'} />
259+
{currentMap.op !== 'screenshot' ? (
260+
<ZoomControl position={'topright'} />
261+
) : (
262+
<></>
263+
)}
259264
{isMobile && (
260265
<DummyControlComponent
261266
position={'topright'}
262267
customComponent={MobileSpaceDisplay}
263268
/>
264269
)}
265-
<CustomControlMap position={'topright'}>
266-
{showUncertaintyControl && (
267-
<Box
268-
className="leaflet-bar"
269-
style={{ backgroundColor: 'white', padding: '2px' }}
270-
>
271-
<UncertaintySwitch
272-
enabled={true}
273-
setShowUncertainty={setShowUncertainty}
274-
currentUncertainty={showUncertainty}
275-
></UncertaintySwitch>
276-
</Box>
277-
)}
278-
</CustomControlMap>
270+
{currentMap.op !== 'screenshot' ? (
271+
<CustomControlMap position={'topright'}>
272+
{showUncertaintyControl && (
273+
<Box
274+
className="leaflet-bar"
275+
style={{ backgroundColor: 'white', padding: '2px' }}
276+
>
277+
<UncertaintySwitch
278+
enabled={true}
279+
setShowUncertainty={setShowUncertainty}
280+
currentUncertainty={showUncertainty}
281+
></UncertaintySwitch>
282+
</Box>
283+
)}
284+
</CustomControlMap>
285+
) : (
286+
<> </>
287+
)}
279288
<CustomControlMap position={'topright'}>
280289
<Box
281290
className="leaflet-bar"

src/app/pages/MapPage/index.tsx

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ export function MapPage(props: MapPageProps) {
108108
const isMobile = useMediaQuery(theme.breakpoints.down('def'));
109109
const api = new RequestApi();
110110

111+
const [caption, setCaption] = useState('');
112+
111113
const [currentLayer, setCurrentLayer] = useState('');
112114
const [currentLayerConfig, setCurrentLayerConfig] = useState({});
113115
const [currentTimeSerie, setCurrentTimeSerie] = useState({});
@@ -453,6 +455,7 @@ export function MapPage(props: MapPageProps) {
453455
...paramsToObject(sp),
454456
...{ lat: selectedPoint.latlng.lat, lng: selectedPoint.latlng.lng },
455457
});
458+
456459
api
457460
.getTimeserieV2(
458461
currentLayer,
@@ -469,6 +472,45 @@ export function MapPage(props: MapPageProps) {
469472
}
470473
}, [selectedPoint, currentLayer]);
471474

475+
useEffect(() => {
476+
let year = '';
477+
try {
478+
year =
479+
currentMap.aggregation_period === 'annual' ||
480+
currentMap.aggregation_period === 'test'
481+
? new Date((mapRef.current as any).timeDimension?.getCurrentTime())
482+
.getFullYear()
483+
.toString()
484+
: '';
485+
console.log('showing year', year);
486+
} catch (e) {
487+
// console.log('no year');
488+
}
489+
const lcaption = `${isMobile
490+
? currentMap.climatological_variable
491+
: labelFor(currentMap.climatological_variable)
492+
}
493+
- ${joinNames([
494+
labelFor(currentMap.climatological_model),
495+
labelFor(currentMap.scenario),
496+
])}
497+
- ${joinNames([
498+
labelFor(currentMap.aggregation_period),
499+
labelFor(currentMap.measure),
500+
])}
501+
${currentMap.time_window && currentMap.aggregation_period === '30yr'
502+
? labelFor(currentMap.time_window)
503+
: ''
504+
}
505+
- ${labelFor(currentMap.year_period)}
506+
${currentMap.aggregation_period != '30yr' && currentYear
507+
? ` - Anno ${year}`
508+
: ''
509+
} `; // string or function, added caption to bottom of screen
510+
511+
setCaption(lcaption);
512+
}, [currentMap]);
513+
472514
const PLUGIN_OPTIONS: PluginOptions = {
473515
cropImageByInnerWH: true, // crop blank opacity from image borders
474516
hidden: true, // hide screen icon
@@ -532,28 +574,6 @@ export function MapPage(props: MapPageProps) {
532574

533575
setInProgress(true);
534576

535-
const caption = `${isMobile
536-
? currentMap.climatological_variable
537-
: labelFor(currentMap.climatological_variable)
538-
}
539-
- ${joinNames([
540-
labelFor(currentMap.climatological_model),
541-
labelFor(currentMap.scenario),
542-
])}
543-
- ${joinNames([
544-
labelFor(currentMap.aggregation_period),
545-
labelFor(currentMap.measure),
546-
])}
547-
${currentMap.time_window && currentMap.aggregation_period === '30yr'
548-
? labelFor(currentMap.time_window)
549-
: ''
550-
}
551-
- ${labelFor(currentMap.year_period)}
552-
${currentMap.aggregation_period != '30yr' && currentYear
553-
? ` - Anno ${year}`
554-
: ''
555-
} © ARPAV - Arpa FVG`; // string or function, added caption to bottom of screen
556-
557577
let filename = `Screenshot ${labelFor(
558578
currentMap.climatological_variable,
559579
)} - ${joinNames([
@@ -571,8 +591,8 @@ export function MapPage(props: MapPageProps) {
571591
}.${
572592
//@ts-ignore
573593
navigator?.userAgentData?.platform.toLowerCase().indexOf('linux') >= 0
574-
? 'jpg'
575-
: 'jpg'
594+
? 'png'
595+
: 'png'
576596
}`;
577597
filename = filename.replaceAll('_', '');
578598

@@ -678,6 +698,25 @@ export function MapPage(props: MapPageProps) {
678698
currentMap={currentMap}
679699
/>
680700

701+
{currentMap.op !== 'screenshot' ? (
702+
<></>
703+
) : (
704+
<div
705+
style={{
706+
display: 'flex',
707+
flexDirection: 'row',
708+
color: 'white',
709+
backgroundColor: 'rgb(22, 77, 54)',
710+
}}
711+
>
712+
<Typography style={{ paddingLeft: '5px' }}>{caption}</Typography>
713+
<span style={{ flex: '1 1 1px' }}></span>
714+
<Typography style={{ paddingRight: '5px' }}>
715+
© ARPAV - Arpa FVG
716+
</Typography>
717+
</div>
718+
)}
719+
681720
{/*TODO Backdrop only for debug?*/}
682721
<Modal open={loading} sx={SpinnerStyle}>
683722
<CircularProgress color="inherit" size={80} />

0 commit comments

Comments
 (0)