From b9947dcb5a527488e560d279d3bb45268afc0b86 Mon Sep 17 00:00:00 2001 From: Jorge Monroy Date: Mon, 2 Dec 2024 14:50:36 -0400 Subject: [PATCH] [TM-1509] initial satellite map (#717) --- src/components/elements/Map-mapbox/Map.tsx | 4 ++-- src/components/elements/Map-mapbox/hooks/useMap.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/elements/Map-mapbox/Map.tsx b/src/components/elements/Map-mapbox/Map.tsx index 2ec1d6580..1f3ea3267 100644 --- a/src/components/elements/Map-mapbox/Map.tsx +++ b/src/components/elements/Map-mapbox/Map.tsx @@ -171,7 +171,7 @@ export const MapContainer = ({ const [showMediaPopups, setShowMediaPopups] = useState(true); const [sourcesAdded, setSourcesAdded] = useState(false); const [viewImages, setViewImages] = useState(false); - const [currentStyle, setCurrentStyle] = useState(isDashboard ? MapStyle.Street : MapStyle.Satellite); + const [currentStyle, setCurrentStyle] = useState(MapStyle.Satellite); const { polygonsData, bbox, setPolygonFromMap, polygonFromMap, sitePolygonData, selectedCountry, setLoader } = props; const context = useSitePolygonData(); const contextMapArea = useMapAreaContext(); @@ -207,7 +207,7 @@ export const MapContainer = ({ mapFunctions; useEffect(() => { - initMap(isDashboard); + initMap(); return () => { if (map.current) { setStyleLoaded(false); diff --git a/src/components/elements/Map-mapbox/hooks/useMap.ts b/src/components/elements/Map-mapbox/hooks/useMap.ts index dc21b87e8..1bd309d00 100644 --- a/src/components/elements/Map-mapbox/hooks/useMap.ts +++ b/src/components/elements/Map-mapbox/hooks/useMap.ts @@ -38,13 +38,12 @@ export const useMap = (onSave?: (geojson: any, record: any) => void) => { const geojson = convertToGeoJSON(featureCollection); onSave?.(geojson, record); }; - const initMap = (isDashboard?: string) => { + const initMap = () => { if (map.current) return; - const mapStyle = isDashboard ? MapStyle.Street : MapStyle.Satellite; map.current = new mapboxgl.Map({ container: mapContainer.current as HTMLDivElement, - style: mapStyle, + style: MapStyle.Satellite, zoom: zoom, accessToken: mapboxToken });