import { useRef, useState, useEffect } from 'react' import { useConfig } from '../../hooks/useConfig' import { useMap } from '../../hooks/useMap' import { useAnalysisLayers } from '../../hooks/useAnalysisLayers' import MapLegend from '../MapLegend/MapLegend' import LayerOpacitySlider from '../LayerOpacitySlider/LayerOpacitySlider' import { IconPlus, IconMinus, IconMapPin } from '@tabler/icons-react' import { Tooltip } from '@mantine/core' import styles from './MapView.module.css'; function MapView({ selectedLocation, onLocationSelect, analysisResult, layersConfig }) { const mapContainerRef = useRef(null); const { mapboxAccessToken } = useConfig(); const [localOpacity, setLocalOpacity] = useState(0.5); const { mapInstance, isMapLoaded, handleZoomIn, handleZoomOut, handleFlyBackToAnalysis } = useMap( mapContainerRef, mapboxAccessToken, selectedLocation, analysisResult ); useAnalysisLayers( mapInstance, isMapLoaded, analysisResult, layersConfig, localOpacity, ); useEffect(() => { if (!isMapLoaded || !mapInstance) return; const handleMapClick = (e) => { const { lng, lat } = e.lngLat; onLocationSelect({ lat, lng, isSearch: false }); }; mapInstance.on('click', handleMapClick); return () => mapInstance.off('click', handleMapClick); }, [isMapLoaded, mapInstance, onLocationSelect]); return (
{analysisResult && ( <> )}
); } export default MapView;