1
- import { MapContainer , useMap , TileLayer , ImageOverlay , GeoJSON , Popup } from "react-leaflet" ;
2
- import { memo , useEffect , useMemo , useRef } from "react" ;
1
+ import { MapContainer , useMap , TileLayer , ImageOverlay } from "react-leaflet" ;
2
+ import { useEffect , useMemo , useRef } from "react" ;
3
3
import { LatLngBounds , Map } from "leaflet" ;
4
4
import { useRecoilState , useRecoilValue } from "recoil" ;
5
- import { appState } from "../state/app" ;
5
+ import { appState } from "../../ state/app" ;
6
6
import { NavigraphRasterSource , NavigraphTheme , NavigraphTileLayer , PresetConfig } from "@navigraph/leaflet" ;
7
- import { userState } from "../state/user" ;
7
+ import { userState } from "../../ state/user" ;
8
8
import { NavigraphAuth } from "@navigraph/auth" ;
9
9
import { Scope } from "@navigraph/app" ;
10
10
11
11
import "leaflet/dist/leaflet.css"
12
- import { mapFaaState , mapSourceState , mapTacState , mapThemeState } from "../state/mapStyle" ;
13
- import { chartOverlayOpacityState , chartOverlayState } from "../state/chartOverlay" ;
12
+ import { mapFaaState , mapSourceState , mapTacState , mapThemeState } from "../../ state/mapStyle" ;
13
+ import { chartOverlayOpacityState , chartOverlayState } from "../../ state/chartOverlay" ;
14
14
import { calculateChartBounds } from "@navigraph/charts" ;
15
15
import { useQuery } from "@tanstack/react-query" ;
16
- import { protectedPage } from "./protectedPage" ;
16
+ import { protectedPage } from ".. /protectedPage" ;
17
17
import { TbCircleX } from "react-icons/tb" ;
18
- import Button from "./Button" ;
19
- import { AmdbLayerName } from "@navigraph/amdb" ;
20
- import { amdbLayersState } from "../state/amdb" ;
18
+ import Button from "../Button" ;
19
+ import AmdbManager from "./amdb" ;
21
20
22
21
export function createPreset ( source : NavigraphRasterSource , theme : NavigraphTheme , faa : boolean , tac : boolean ) : PresetConfig {
23
22
if ( source === 'WORLD' ) {
@@ -30,27 +29,6 @@ export function createPreset(source: NavigraphRasterSource, theme: NavigraphThem
30
29
return { source, theme, type : faa ? 'FAA' : 'Navigraph' }
31
30
}
32
31
33
- const AmdbLayer = protectedPage < { idarpt : string , layers : AmdbLayerName [ ] } , [ Scope . AMDB ] > ( memo ( ( { idarpt, layers, amdb } ) => {
34
- const { data } = useQuery ( {
35
- queryKey : [ 'amdb-data' , idarpt , layers ] ,
36
- queryFn : async ( ) => {
37
- return amdb . getAmdbLayers ( { icao : idarpt , include : [ 'aerodromereferencepoint' , ...layers ] } )
38
- }
39
- } )
40
-
41
- if ( ! data ) return null ;
42
-
43
- return (
44
- Object . entries ( data ) . map ( ( [ layerName , data ] ) =>
45
- < GeoJSON data = { data } >
46
- < Popup >
47
- { layerName }
48
- </ Popup >
49
- </ GeoJSON >
50
- )
51
- )
52
- } ) , [ Scope . AMDB ] ) ;
53
-
54
32
const ChartOverlay = protectedPage ( ( { charts } ) => {
55
33
const theme = useRecoilValue ( mapThemeState ) ;
56
34
@@ -153,8 +131,6 @@ export default function MapPane() {
153
131
const app = useRecoilValue ( appState ) ;
154
132
const user = useRecoilValue ( userState ) ;
155
133
156
- const amdbLayers = useRecoilValue ( amdbLayersState ) ;
157
-
158
134
return (
159
135
< div className = 'w-full' >
160
136
< MapContainer center = { [ 51.505 , - 0.09 ] } zoom = { 13 } className = 'h-screen' zoomControl = { false } ref = { mapRef } whenReady = { ( ) => {
@@ -170,7 +146,7 @@ export default function MapPane() {
170
146
/>
171
147
) }
172
148
< ChartOverlay />
173
- { amdbLayers . map ( ( layer ) => < AmdbLayer key = { layer [ 0 ] } idarpt = { layer [ 0 ] } layers = { layer [ 1 ] } /> ) }
149
+ < AmdbManager />
174
150
</ MapContainer >
175
151
</ div >
176
152
)
0 commit comments