"use client"; import "./ReportMap.scss"; import "leaflet/dist/leaflet.css"; import { MapContainer, Marker, Polyline, Popup, TileLayer, } from "react-leaflet"; import geo_green_icon from "./icons/geo-green.svg"; import geo_orange_icon from "./icons/geo-orange.svg"; import geo_pink_icon from "./icons/geo-pink.svg"; import geo_purple_icon from "./icons/geo-purple.svg"; import geo_red_icon from "./icons/geo-red.svg"; import geo_yellow_icon from "./icons/geo-yellow.svg"; import { DivIcon, Icon, LatLngTuple } from "leaflet"; import { StaticImageData } from "next/image"; import { ILocation } from "@/shared/types/location-type"; import { Link } from "@/shared/config/navigation"; import { useReportStore } from "../reportStore"; interface IReportMapProps { location: ILocation[]; category: number; } const ReportMap: React.FC = ({ location, category, }: IReportMapProps) => { const { showMap } = useReportStore(); const createCustomIcon = (icon: StaticImageData) => { const customIcon = new Icon({ iconUrl: icon.src, iconSize: [32, 32], }); return customIcon; }; const icons: Record = { 1: createCustomIcon(geo_red_icon), 2: createCustomIcon(geo_pink_icon), 3: createCustomIcon(geo_purple_icon), 4: createCustomIcon(geo_orange_icon), 5: createCustomIcon(geo_yellow_icon), 6: createCustomIcon(geo_green_icon), }; const categoryToPolyline: Record = { 1: { color: "rgba(230, 68, 82, 0.8)" }, 2: { color: "rgba(198, 152, 224, 0.8)" }, 3: { color: "rgba(135, 40, 157, 0.8)" }, 4: { color: "rgba(247, 181, 84, 0.8)" }, 5: { color: "rgba(254, 211, 99, 0.8)" }, 6: { color: "rgba(158, 221, 128, 0.8)" }, }; const position = { lat: +location[0].latitude, lng: +location[0].longitude, }; return showMap ? ( {location.length === 2 ? ( ) : null} {location.map((marker) => (

{marker.address}

))}
) : null; }; export default ReportMap;