@@ -59,9 +59,11 @@ export const TWLSample = (props: any) => {
5959 } , [ tLayer ] ) ;
6060
6161 const setCurrYear = yr => {
62+ const date = new Date ( ) ;
63+ date . setFullYear ( yr + 1 ) ;
6264 setCurrentYear ( yr ) ;
6365 //@ts -ignore
64- context . map . timeDimension . setCurrentTime ( yr ) ;
66+ context . map . timeDimension . setCurrentTime ( date . getTime ( ) ) ;
6567 } ;
6668
6769 useEffect ( ( ) => {
@@ -72,6 +74,7 @@ export const TWLSample = (props: any) => {
7274 url . searchParams . has ( 'op' ) &&
7375 url . searchParams . get ( 'op' ) === 'screenshot'
7476 ) {
77+ setIsSh ( true ) ;
7578 if ( url . searchParams . has ( 'year' ) ) {
7679 const y = url . searchParams . get ( 'year' ) ;
7780 if ( y ) {
@@ -89,6 +92,7 @@ export const TWLSample = (props: any) => {
8992 url . searchParams . has ( 'op' ) &&
9093 url . searchParams . get ( 'op' ) === 'screenshot'
9194 ) {
95+ setIsSh ( true ) ;
9296 } else {
9397 let dt = new Date ( + data . time ) . getFullYear ( ) ;
9498 console . log ( 'setting current year from Leaflet Timedmension:' , dt ) ;
@@ -240,23 +244,39 @@ export const TWLSample = (props: any) => {
240244 cacheForward : 0 ,
241245 } ) ;
242246
243- if ( currentMap === 'annual' && ! isSh ) {
247+ if ( currentMap === 'annual' ) {
244248 setLayer ( tdWmsLayer2 ) ;
245- setTimeout ( ( ) => {
249+ if ( ! isSh ) {
250+ setTimeout ( ( ) => {
251+ try {
252+ // @ts -ignore
253+ map . _controlContainer . getElementsByClassName (
254+ 'leaflet-bar-timecontrol' ,
255+ ) [ 0 ] . style . display = 'flex' ;
256+ // @ts -ignore
257+ map . _controlContainer . getElementsByClassName (
258+ 'leaflet-time-info' ,
259+ ) [ 0 ] . style . display = 'flex' ;
260+ setTimestatus ( 'flex' ) ;
261+ } catch ( e ) {
262+ // console.log(e)
263+ }
264+ } , 250 ) ;
265+ } else {
246266 try {
247267 // @ts -ignore
248268 map . _controlContainer . getElementsByClassName (
249269 'leaflet-bar-timecontrol' ,
250- ) [ 0 ] . style . display = 'flex ' ;
270+ ) [ 0 ] . style . display = 'none ' ;
251271 // @ts -ignore
252272 map . _controlContainer . getElementsByClassName (
253273 'leaflet-time-info' ,
254- ) [ 0 ] . style . display = 'flex ' ;
255- setTimestatus ( 'flex ' ) ;
274+ ) [ 0 ] . style . display = 'none ' ;
275+ setTimestatus ( 'none ' ) ;
256276 } catch ( e ) {
257277 // console.log(e)
258278 }
259- } , 250 ) ;
279+ }
260280 layer . current = tdWmsLayer2 ;
261281 currentLayer = tdWmsLayer2 ;
262282 setTLayer ( tdWmsLayer2 ) ;
0 commit comments