Files
meshtastic-web/src/components/Map.tsx
T
Dan DitomasoandGitHub ec9b299b37 fix: add missing i18n strings (#671)
* fix: added required i18n labels to UI

* added node i18n

* updated tests

* updated path to match github action
2025-06-18 16:25:14 -04:00

62 lines
1.6 KiB
TypeScript

import MapGl, {
AttributionControl,
type MapRef,
NavigationControl,
ScaleControl,
} from "react-map-gl/maplibre";
import { useTheme } from "@core/hooks/useTheme.ts";
import { useEffect, useRef } from "react";
interface MapProps {
children?: React.ReactNode;
onLoad?: (map: MapRef) => void;
}
export const Map = ({ children, onLoad }: MapProps) => {
const { theme } = useTheme();
const darkMode = theme === "dark";
const mapRef = useRef<MapRef | null>(null);
useEffect(() => {
const map = mapRef.current;
if (map && onLoad) onLoad(map);
}, [onLoad]);
return (
<MapGl
ref={mapRef}
mapStyle="https://raw.githubusercontent.com/hc-oss/maplibre-gl-styles/master/styles/osm-mapnik/v8/default.json"
attributionControl={false}
renderWorldCopies={false}
maxPitch={0}
dragRotate={false}
touchZoomRotate={false}
initialViewState={{
zoom: 1.8,
latitude: 35,
longitude: 0,
}}
style={{ filter: darkMode ? "brightness(0.9)" : undefined }}
>
<AttributionControl
style={{
background: darkMode ? "#ffffff" : undefined,
color: darkMode ? "black" : undefined,
}}
/>
{/* { Disabled for now until we can use i18n for the geolocate control} */}
{
/* <GeolocateControl
position="top-right"
i18nIsDynamicList
positionOptions={{ enableHighAccuracy: true }}
trackUserLocation
/> */
}
<NavigationControl position="top-right" showCompass={false} />
<ScaleControl />
{children}
</MapGl>
);
};