Skip to content

Commit

Permalink
Update to edit mode on drawn feature
Browse files Browse the repository at this point in the history
  • Loading branch information
weberjavi committed Apr 15, 2024
1 parent c50cd1a commit 2ef52a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/fishing-map/features/map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import MapAnnotations from './overlays/annotations/Annotations'
import MapAnnotationsDialog from './overlays/annotations/AnnotationsDialog'
import useRulers from './overlays/rulers/rulers.hooks'
import { useDrawLayer } from './overlays/draw/draw.hooks'
import { useMapDrawConnect } from './map-draw.hooks'
// This avoids type checking to complain
// https://github.com/visgl/deck.gl/issues/7304#issuecomment-1277850750
const RulersLayerComponent = RulersLayer as any
Expand Down
5 changes: 3 additions & 2 deletions apps/fishing-map/features/map/overlays/draw/draw.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ const drawLayerModeAtom = atom<DrawLayerMode>('draw')
export const useDrawLayer = () => {
const [drawFeatures, setDrawFeatures] = useAtom(drawFeaturesAtom)
const [drawFeaturesIndexes, setDrawFeaturesIndexes] = useAtom(drawFeaturesIndexesAtom)
const drawLayerMode = useAtomValue(drawLayerModeAtom)
const [drawLayerMode, setDrawLayerMode] = useAtom(drawLayerModeAtom)
const onDrawEdit = useCallback(
({ updatedData, editType }) => {
console.log('🚀 ~ useDrawLayer ~ updatedData, editType:', updatedData, editType)
if (editType === 'addFeature' || editType === 'movePosition' || editType === 'addPosition') {
setDrawFeatures(updatedData)
setDrawLayerMode('edit')
}
},
[setDrawFeatures]
[setDrawFeatures, setDrawLayerMode]
)
const onDrawClick = useCallback(
(info) => {
Expand Down

0 comments on commit 2ef52a1

Please sign in to comment.