import {useMemo, useCallback, useRef} from 'react'; import Map, { Source, Layer, NavigationControl, FullscreenControl, ScaleControl, GeolocateControl, type MapRef } from 'react-map-gl/mapbox'; import {Box} from '@chakra-ui/react'; import type {Feature, FeatureCollection, Point} from 'geojson'; import PORTS from './test_data/nautical-base-data.json'; import type {VesselData} from './ais-provider'; export interface Geolocation { clearWatch(watchId: number): void; getCurrentPosition( successCallback: PositionCallback, errorCallback?: PositionErrorCallback | null, options?: PositionOptions ): void; watchPosition( successCallback: PositionCallback, errorCallback?: PositionErrorCallback | null, options?: PositionOptions ): number; } interface MapNextProps { mapboxPublicKey: string; geolocation: Geolocation; vesselPosition?: any; layer?: any; mapView?: any; aisVessels?: VesselData[]; onVesselClick?: (vessel: VesselData) => void; vesselPopup?: VesselData | null; onVesselPopupClose?: () => void; } export default function GeoMap(props: MapNextProps) { const mapRef = useRef(null); const portsGeoJSON = useMemo>(() => ({ type: 'FeatureCollection', features: PORTS.map(port => ({ type: 'Feature', geometry: {type: 'Point', coordinates: [port.longitude, port.latitude]}, properties: {city: port.city, state: port.state} } as Feature)) }), []); const handleGeolocate = useCallback((pos: GeolocationPosition) => { console.log('User location loaded:', pos); }, []); return ( ); }