import { Box, useTheme } from "@mui/material"; import L from "leaflet"; import "leaflet/dist/leaflet.css"; import { useMemo } from "react"; import { MapContainer, Marker, TileLayer, useMap } from "react-leaflet"; import { MapLoaderProps } from "./MapLoader.tsx"; // @ts-ignore delete L.Icon.Default.prototype._getIconUrl; L.Icon.Default.mergeOptions({ iconUrl: "/static/img/marker-icon.png", // .src removed iconRetinaUrl: "/static/img/marker-icon-2x.png", // .src removed shadowUrl: "/static/img/marker-shadow.png", // .src removed }); const includeUkraineFlag = false; const FlagRemoval = () => { const map = useMap(); if (!includeUkraineFlag) { map.attributionControl.setPrefix( 'Leaflet', ); } return null; }; const LeafletMapBox = ({ center, height, mapProvider, googleTileType, sx, ...rest }: MapLoaderProps) => { const theme = useTheme(); const googleTileUrl = useMemo(() => { switch (googleTileType) { case "terrain": return "http://{s}.google.com/vt/lyrs=p&x={x}&y={y}&z={z}"; case "satellite": return "http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}"; default: return "http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}"; } }, [googleTileType]); return ( {/* OPEN STREEN MAPS TILES */} {mapProvider == "openstreetmap" && ( )} {/* GOOGLE MAPS TILES */} {mapProvider == "google" && ( )} ); }; export default LeafletMapBox;