@@ -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