diff --git a/src/frontend/src/components/MapComponent/OpenLayersComponent/LayerSwitcher/index.js b/src/frontend/src/components/MapComponent/OpenLayersComponent/LayerSwitcher/index.js index 7bf5798c2b..7b90cea7cc 100644 --- a/src/frontend/src/components/MapComponent/OpenLayersComponent/LayerSwitcher/index.js +++ b/src/frontend/src/components/MapComponent/OpenLayersComponent/LayerSwitcher/index.js @@ -204,7 +204,8 @@ const LayerSwitcherControl = ({ map, visible = 'osm', pmTileLayerUrl = null }) = location.pathname.includes('upload-area') || location.pathname.includes('upload-survey') || location.pathname.includes('map-features') || - location.pathname.includes('split-tasks') + location.pathname.includes('split-tasks') || + location.pathname.includes('project-submissions') ) { const olZoom = document.querySelector('.ol-zoom'); if (olZoom) { diff --git a/src/frontend/src/components/SubmissionMap/MapControlComponent.tsx b/src/frontend/src/components/SubmissionMap/MapControlComponent.tsx new file mode 100644 index 0000000000..4c5b7e96a4 --- /dev/null +++ b/src/frontend/src/components/SubmissionMap/MapControlComponent.tsx @@ -0,0 +1,63 @@ +import React from 'react'; +import AssetModules from '@/shared/AssetModules'; +import VectorLayer from 'ol/layer/Vector'; +import * as olExtent from 'ol/extent'; + +const MapControlComponent = ({ map }) => { + const btnList = [ + { + id: 'Add', + icon: , + }, + { + id: 'Minus', + icon: , + }, + { + id: 'Zoom To Layer', + icon: , + }, + ]; + + const handleOnClick = (btnId) => { + if (btnId === 'Add') { + const actualZoom = map.getView().getZoom(); + map.getView().setZoom(actualZoom + 1); + } else if (btnId === 'Minus') { + const actualZoom = map.getView().getZoom(); + map.getView().setZoom(actualZoom - 1); + } else if (btnId === 'Zoom To Layer') { + const extent = olExtent.createEmpty(); + const layers = map?.getLayers(); + + layers?.forEach((layer) => { + if (layer instanceof VectorLayer) { + olExtent.extend(extent, layer.getSource().getExtent()); + } + }); + map?.getView()?.fit(extent, { + padding: [50, 50, 50, 50], + duration: 900, + }); + } + }; + + return ( +
+ {btnList.map((btn) => { + return ( +
+
handleOnClick(btn.id)} + > + {btn.icon} +
+
+ ); + })} +
+ ); +}; + +export default MapControlComponent; diff --git a/src/frontend/src/components/SubmissionMap/SubmissionInstanceMap.tsx b/src/frontend/src/components/SubmissionMap/SubmissionInstanceMap.tsx index 1a3ebbd3b5..e5febf8860 100644 --- a/src/frontend/src/components/SubmissionMap/SubmissionInstanceMap.tsx +++ b/src/frontend/src/components/SubmissionMap/SubmissionInstanceMap.tsx @@ -11,6 +11,7 @@ import { Stroke } from 'ol/style'; import { hexToRgba } from '@/components/MapComponent/OpenLayersComponent/helpers/styleUtils'; import { Fill } from 'ol/style'; import { geojsonType } from '@/store/types/ISubmissions'; +import MapControlComponent from '@/components/SubmissionMap/MapControlComponent'; type submissionInstanceMapPropType = { featureGeojson: { vectorLayerGeojson: geojsonType; clusterLayerGeojson: geojsonType }; @@ -61,6 +62,7 @@ const SubmissionInstanceMap = ({ featureGeojson }: submissionInstanceMapPropType
+ {featureGeojson?.vectorLayerGeojson?.type && ( )} {isDrawOrGeojsonFile && !splittedGeojson && ( @@ -80,6 +82,7 @@ const NewDefineAreaMap = ({ onModify={onModify} zoomToLayer getAOIArea={getAOIArea} + style={{ ...defaultStyles, lineColor: '#0fffff', lineThickness: 2, fillOpacity: 10, fillColor: '#000000' }} /> )} @@ -93,6 +96,7 @@ const NewDefineAreaMap = ({ duration: 500, }} zoomToLayer + style={{ ...defaultStyles, lineColor: '#D73F37', lineThickness: 1.5, fillColor: '#D73F37' }} /> )} {buildingExtractedGeojson && ( @@ -105,6 +109,7 @@ const NewDefineAreaMap = ({ duration: 500, }} zoomToLayer + style={{ ...defaultStyles, lineColor: '#1a2fa2', fillOpacity: 30, lineOpacity: 50 }} /> )} {lineExtractedGeojson && (