Files
frontend/apps/sn/app/(map-layout)/map/waterDepth/waterDepth.tsx
T

97 lines
3.4 KiB
TypeScript

"use client";
import React, { useRef, useEffect, useState } from "react";
import { Label } from "@common/components/ui/label";
export const WATER_DEPTH_LAYER_TYPES: string[] = [
'tb_ms_flood_dngr_map',
'tb_ms_sbmrg_dngr_map'
];
// 지정된 순서에 따른 lyr_sn 배열
export const ORDERED_LAYERS: string[] = [
'27', // 침수위험지도(tb_ms_sbmrg_dngr_map) - 30년 빈도
'28', // 침수위험지도(tb_ms_sbmrg_dngr_map) - 50년 빈도
'3', // 침수위험지도(tb_ms_sbmrg_dngr_map) - 80년 빈도
'4', // 침수위험지도(tb_ms_sbmrg_dngr_map) - 100년 빈도
'59', // 도시침수지도(tb_ms_flood_dngr_map) - 30년 빈도
'60', // 도시침수지도(tb_ms_flood_dngr_map) - 50년 빈도
'58' // 도시침수지도(tb_ms_flood_dngr_map) - 80년 빈도
];
interface WaterDepthProps {
onClose?: () => void;
isPlaying: boolean;
setIsPlaying: (isPlaying: boolean) => void;
totalSteps?: number;
currentStep?: number;
}
export function WaterDepth({
onClose,
isPlaying,
setIsPlaying,
totalSteps = 0,
currentStep = 0,
}: WaterDepthProps) {
useEffect(() => {
if (setIsPlaying) setIsPlaying(isPlaying);
}, [isPlaying, setIsPlaying]);
const handlePlayToggle = () => {
setIsPlaying(!isPlaying);
};
// 진행률 계산 (0-100%)
const progressPercentage = totalSteps > 0 ? (currentStep / totalSteps) * 100 : 100;
return (
<>
<div className="bg-white rounded-lg shadow-lg border border-gray-200 w-[160px] px-4 py-3">
<div className="flex items-center justify-between mx-2 my-4">
<Label className="text-3xl text-gray-900 font-bold">침수심 범례</Label>
<button type="button" className="ml-2" onClick={handlePlayToggle}>
{isPlaying ? (
<img src="/images/map/toolbar/pause_button.png" alt="pause" className="w-6 h-6 object-contain" />
) : (
<img src="/images/map/toolbar/play_button_arrowhead.png" alt="play" className="w-6 h-6 object-contain" />
)}
</button>
</div>
<div className="mb-3">
<div className="w-full bg-gray-200 rounded-full h-1">
<div
className="bg-blue-900 h-1 rounded-full transition-all duration-300 ease-in-out"
style={{ width: `${progressPercentage}%` }}
/>
</div>
</div>
<div className="w-[140px] mx-auto flex flex-col items-center">
<div className="bg-blue-900 text-white text-2xl text-center py-1 mb-2 rounded w-full">침 수 심</div>
<div className="space-y-1 w-full">
<LegendItem color="#0000ff" label="0.3~0.5m 미만" />
<LegendItem color="#00e8fe" label="0.5~1.0m 미만" />
<LegendItem color="#00fdb7" label="1.0~1.5m 미만" />
<LegendItem color="#00fe4e" label="1.5~2.0m 미만" />
<LegendItem color="#fce800" label="2.0~3.0m 미만" />
<LegendItem color="#fe0000" label="3.0m 이상" />
</div>
<div className="border-t-2 border-blue-900 mt-1 mx-auto w-full" />
</div>
</div>
</>
);
}
function LegendItem({ color, label }: { color: string; label: string }) {
return (
<div className="flex items-center gap-2 w-full">
<span
className="inline-block w-16 h-6"
style={{ backgroundColor: color, border: "1px solid #ccc" }}
/>
<span className="text-xl text-gray-900 font-bold">{label}</span>
</div>
);
}