Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sirmmo committed Dec 3, 2024
1 parent ba94d6c commit 3d3b900
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/app/components/Map/TWLSample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ export const TWLSample = (props: any) => {
map.timeDimension.on('timeloading', data => {
let dt = new Date(+data.time).getFullYear();
setCurrentYear(dt);

let layers = document.getElementsByClassName('leaflet-layer');
//@ts-ignore
for (const t of layers) {
if (t.style.display === 'none') {
t.style.display = 'block';
}
}
});
// @ts-ignore
//if (!map.setupFrontLayer) map.setupFrontLayer = setupFrontLayer;
Expand Down
21 changes: 20 additions & 1 deletion src/app/components/Map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const Map = (props: MapProps) => {

const timeDimensionOptions = {
times: '1976-01-01T00:00:00Z/2099-01-01T23:59:59Z/P1Y',
minBufferReady: 0,
};

const [click, setClick] = React.useState();
Expand All @@ -136,6 +137,8 @@ const Map = (props: MapProps) => {
type: 'FeatureCollection',
features: [],
});

const player = useRef();
const [opacity, doSetOpacity] = React.useState(0.85);

useEffect(() => {
Expand Down Expand Up @@ -170,9 +173,25 @@ const Map = (props: MapProps) => {
backwardButton: true,
forwardButton: true,
playButton: false,
player: player.current,
}}
timeDimensionPlayerOptions={{
minBufferReady: 0,
}}
//@ts-ignore
whenReady={obj => onReady(obj.target)}
whenReady={obj => {
onReady(obj.target);
//@ts-ignore
player.current = new L.TimeDimension.Player(
{
buffer: 0,
minBufferReady: 0,
},
obj.target.timeDimension,
).on('play', () => {
console.log('play!!');
});
}}
>
<ScaleControl imperial={false} />

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/TimeSeriesDialog/TSDataContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ const TSDataContainer = (props: TSDataContainerProps) => {
setTimeRange({
...{
start: 0,
end: 2100 - baseValue,
end: 2099 - baseValue,
},
...{
start: localStartYear - baseValue,
Expand Down
8 changes: 4 additions & 4 deletions src/app/pages/MapPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,12 @@ export function MapPage(props: MapPageProps) {
let year = '';
try {
year =
currentMap.data_series === 'yes'
currentMap.aggregation_period === 'annual'
? new Date((mapRef.current as any).timeDimension?.getCurrentTime())
.getFullYear()
.toString()
: '';
console.log('showing yrar', year);
console.log('showing year', year);
} catch (e) {
// console.log('no year');
}
Expand All @@ -393,7 +393,7 @@ export function MapPage(props: MapPageProps) {
}
- ${labelFor(currentMap.year_period)}
${currentMap.aggregation_period != '30yr' && currentYear
? ` - Anno ${currentYear - 1}`
? ` - Anno ${year}`
: ''
} © ARPAV - Arpa FVG`; // string or function, added caption to bottom of screen

Expand All @@ -409,7 +409,7 @@ export function MapPage(props: MapPageProps) {
? ' - ' + labelFor(currentMap.time_window)
: ''
} - ${labelFor(currentMap.year_period)} ${currentMap.aggregation_period != '30yr' && currentYear
? ` - Anno ${currentYear - 1}`
? ` - Anno ${year}`
: ''
}.${
//@ts-ignore
Expand Down

0 comments on commit 3d3b900

Please sign in to comment.