diff --git a/src/frontend/src/components/MapComponent/OpenLayersComponent/Layers/VectorLayer.js b/src/frontend/src/components/MapComponent/OpenLayersComponent/Layers/VectorLayer.js index f88a824ef3..f4ef884ede 100644 --- a/src/frontend/src/components/MapComponent/OpenLayersComponent/Layers/VectorLayer.js +++ b/src/frontend/src/components/MapComponent/OpenLayersComponent/Layers/VectorLayer.js @@ -50,6 +50,7 @@ const VectorLayer = ({ getTaskStatusStyle, layerProperties, rotation, + getAOIArea, }) => { const [vectorLayer, setVectorLayer] = useState(null); useEffect(() => () => map && vectorLayer && map.removeLayer(vectorLayer), [map, vectorLayer]); @@ -135,6 +136,7 @@ const VectorLayer = ({ }); map.addInteraction(draw); return () => { + map.removeInteraction(draw); // map.removeInteraction(snap); }; }, [map, vectorLayer, onDraw]); @@ -299,6 +301,13 @@ const VectorLayer = ({ } }, [rotation, map, geojson]); + useEffect(() => { + if (!vectorLayer || !getAOIArea) return; + const geometry = vectorLayer.getSource().getFeatures()?.[0].getGeometry(); + const area = formatArea(geometry); + getAOIArea(area); + }, [vectorLayer, getAOIArea]); + // ROTATE MAP ACCORDING TO ORIENTATION // useEffect(() => { // if (!map) return; diff --git a/src/frontend/src/components/common/StepSwitcher.tsx b/src/frontend/src/components/common/StepSwitcher.tsx index aa6467d4ab..c16cdcf866 100644 --- a/src/frontend/src/components/common/StepSwitcher.tsx +++ b/src/frontend/src/components/common/StepSwitcher.tsx @@ -36,7 +36,7 @@ const StepSwitcher = ({ data, flag, switchSteps }) => {
= index ? 'fmtm-bg-primaryRed' : 'fmtm-bg-transparent' }`} onClick={() => { diff --git a/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx b/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx index 6e20701de5..91b6ee42a9 100644 --- a/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx +++ b/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx @@ -87,17 +87,17 @@ const ProjectDetailsForm = ({ flag }) => { information about your project. To complete the first step, you will need the login credentials of ODK Central Server.{' '} -
- - Here are the instructions for setting up a Central ODK Server on Digital Ocean, if you haven’t already. - +
- https://docs.getodk.org/central-install-digital-ocean/ + Here{' '} + + are the instructions for setting up a Central ODK Server on Digital Ocean, if you haven’t already. +
diff --git a/src/frontend/src/components/createnewproject/UploadArea.tsx b/src/frontend/src/components/createnewproject/UploadArea.tsx index 903ef768ab..4ba77621b1 100644 --- a/src/frontend/src/components/createnewproject/UploadArea.tsx +++ b/src/frontend/src/components/createnewproject/UploadArea.tsx @@ -297,12 +297,16 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se { - handleCustomChange('drawnGeojson', geojson); - dispatch(CreateProjectActions.SetDrawnGeojson(JSON.parse(geojson))); - dispatch(CreateProjectActions.SetTotalAreaSelection(area)); - setGeojsonFile(null); - }} + onDraw={ + drawnGeojson || uploadAreaSelection === 'upload_file' + ? null + : (geojson, area) => { + handleCustomChange('drawnGeojson', geojson); + dispatch(CreateProjectActions.SetDrawnGeojson(JSON.parse(geojson))); + dispatch(CreateProjectActions.SetTotalAreaSelection(area)); + setGeojsonFile(null); + } + } onModify={(geojson, area) => { handleCustomChange('drawnGeojson', geojson); dispatch(CreateProjectActions.SetDrawnGeojson(JSON.parse(geojson))); @@ -310,7 +314,9 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se dispatch(CreateProjectActions.ClearProjectStepState(formValues)); setCustomLineUpload(null); setCustomPolygonUpload(null); - setGeojsonFile(null); + }} + getAOIArea={(area) => { + dispatch(CreateProjectActions.SetTotalAreaSelection(area)); }} /> diff --git a/src/frontend/src/views/NewDefineAreaMap.tsx b/src/frontend/src/views/NewDefineAreaMap.tsx index bc9d906e1d..61b70fb753 100644 --- a/src/frontend/src/views/NewDefineAreaMap.tsx +++ b/src/frontend/src/views/NewDefineAreaMap.tsx @@ -12,9 +12,10 @@ type NewDefineAreaMapProps = { uploadedOrDrawnGeojsonFile: GeoJSONFeatureTypes; buildingExtractedGeojson?: GeoJSONFeatureTypes; lineExtractedGeojson?: GeoJSONFeatureTypes; - onDraw?: (geojson: any, area: number) => void; + onDraw?: ((geojson: any, area: number) => void) | null; onModify?: ((geojson: any, area?: number) => void) | null; hasEditUndo?: boolean; + getAOIArea?: ((area?: number) => void) | null; }; const NewDefineAreaMap = ({ drawToggle, @@ -25,6 +26,7 @@ const NewDefineAreaMap = ({ onDraw, onModify, hasEditUndo, + getAOIArea, }: NewDefineAreaMapProps) => { const { mapRef, map } = useOLMap({ // center: fromLonLat([85.3, 27.7]), @@ -71,6 +73,7 @@ const NewDefineAreaMap = ({ onDraw={onDraw} onModify={onModify} zoomToLayer + getAOIArea={getAOIArea} /> )}