-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.tsx
84 lines (76 loc) · 2.38 KB
/
Main.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import DeckGL from '@deck.gl/react';
import { MapViewState } from '@deck.gl/core';
import { FourwingsHeatmapTileLayerProps } from '../layers/fourwings-heatmap.types';
import { FourwingsHeatmapTileLayer } from '../layers/FourwingsHeatmapTileLayer';
import { BaseMapLayer } from '../layers/BasemapLayer';
import { Timebar, TimebarProps } from '@globalfishingwatch/timebar';
import { useState } from 'react';
import {
FOURWINGS_INTERVALS_ORDER,
getFourwingsInterval,
} from '../loaders/helpers/time';
import { getUTCDateTime } from '../layers/fourwings-heatmap.utils';
import styles from './Main.module.css';
import { SatelliteLayer } from '../layers/SatelliteLayer';
const INITIAL_VIEW_STATE: MapViewState = {
longitude: -30,
latitude: 30,
zoom: 3,
};
const AVAILABLE_START = '2020-01-01T00:00:00.000Z';
const AVAILABLE_END = new Date().toISOString();
function Main() {
const isSatellite = false; // TODO: sync state with sidebar
const [{ start, end }, setRange] = useState<{ start: string; end: string }>({
start: '2024-01-01T00:00:00.000Z',
end: '2024-04-01T00:00:00.000Z',
});
const fourwingsLayerProps: FourwingsHeatmapTileLayerProps = {
id: 'ais',
startTime: getUTCDateTime(start).toMillis(),
endTime: getUTCDateTime(end).toMillis(),
sublayers: [
{
id: 'presence',
visible: true,
datasets: ['public-global-presence:v3.0'],
color: '#FF64CE',
colorRamp: 'magenta',
},
],
visible: true,
};
// TODO: sync state with sidebar
const layers = [
isSatellite ? new SatelliteLayer() : new BaseMapLayer(),
new FourwingsHeatmapTileLayer(fourwingsLayerProps),
];
const onChange: TimebarProps['onChange'] = (e) => {
setRange({ start: e.start, end: e.end });
};
return (
<div>
<DeckGL
initialViewState={INITIAL_VIEW_STATE}
controller
layers={layers}
/>
<div className={styles.timebar}>
<Timebar
enablePlayback={false}
start={start}
end={end}
absoluteStart={AVAILABLE_START}
absoluteEnd={AVAILABLE_END}
onChange={onChange}
bookmarkPlacement="bottom"
minimumRange={1}
intervals={FOURWINGS_INTERVALS_ORDER}
getCurrentInterval={getFourwingsInterval}
trackGraphOrientation={'mirrored'}
></Timebar>
</div>
</div>
);
}
export default Main;