diff --git a/appv2/src/UI/Map/ActivityGeo.tsx b/appv2/src/UI/Map/ActivityGeo.tsx index d8f6778bc..567e0fe92 100644 --- a/appv2/src/UI/Map/ActivityGeo.tsx +++ b/appv2/src/UI/Map/ActivityGeo.tsx @@ -4,13 +4,14 @@ import '@geoman-io/leaflet-geoman-free'; import '@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css'; import React, { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { ACTIVITY_UPDATE_GEO_REQUEST } from 'state/actions'; +import { ACTIVITY_TOGGLE_NOTIFICATION_SUCCESS, ACTIVITY_UPDATE_GEO_REQUEST } from 'state/actions'; import { GeoJSON, useMap, useMapEvent } from 'react-leaflet'; import type { LayerGroup } from 'leaflet'; export const GeoEditTools = (props) => { const { map, layerContainer } = useLeafletContext(); const container = (layerContainer as LayerGroup) || map; + const dispatch = useDispatch(); if (!container) { console.warn('[GEOMAN-CONTROLS] No map or container instance found'); @@ -28,6 +29,23 @@ export const GeoEditTools = (props) => { cutPolygon: false, rotateMode: false }); + + // Set up remove button listener workaround + const removeButton = document.getElementsByClassName("leaflet-pm-icon-delete")[0]; + removeButton.addEventListener("click", () => { + map?.pm?.toggleGlobalRemovalMode(); + dispatch({ type: ACTIVITY_UPDATE_GEO_REQUEST, payload: { geometry: [] } }); + dispatch({ + type: ACTIVITY_TOGGLE_NOTIFICATION_SUCCESS, + payload: { + notification: { + visible: true, + message: 'Geometry Removed', + severity: 'success' + } + } + }); + }); }; useEffect(() => { diff --git a/appv2/src/state/sagas/activity/dataAccess.ts b/appv2/src/state/sagas/activity/dataAccess.ts index ffd132614..46b218aa6 100644 --- a/appv2/src/state/sagas/activity/dataAccess.ts +++ b/appv2/src/state/sagas/activity/dataAccess.ts @@ -111,7 +111,20 @@ export function* handle_ACTIVITY_UPDATE_GEO_REQUEST(action) { if (latitude && longitude) utm = calc_utm(longitude, latitude); const reported_area = calculateGeometryArea(action.payload.geometry); - + if (action.payload.geometry.length < 1) { + yield put({ + type: ACTIVITY_UPDATE_GEO_SUCCESS, + payload: { + geometry: action.payload.geometry, + utm: utm, + lat: latitude, + long: longitude, + reported_area: reported_area, + Well_Information: [] + } + }); + return; + } const isPointGeometry = action.payload.geometry[0].geometry.type === 'Point'; if (!isPointGeometry) {