diff --git a/src/components/map/mapbox/draw/LaancDrawControl.js b/src/components/map/mapbox/draw/LaancDrawControl.js index c13f1d3..0df5082 100644 --- a/src/components/map/mapbox/draw/LaancDrawControl.js +++ b/src/components/map/mapbox/draw/LaancDrawControl.js @@ -157,24 +157,36 @@ export const LaancDrawControl = props => { drawObj.setFeatureProperty(newBufferId[0], 'lineId', obj.id); setBufferId(newBufferId[0]); - if (length < 1) { - setAlertModal({ - isOpen: true, + if (length < 2) { + // setAlertModal({ + // isOpen: true, + // title: '좌표 최소 개수', + // desc: '좌표를 두 개 점으로 이어주세요.' + // }); + props.setModal({ title: '좌표 최소 개수', - desc: '좌표를 두 개 점으로 이어주세요.' + desc: <>좌표를 두 개 점으로 이어주세요., + isOpen: true }); handlerRemoveError(obj.id); + return; } } else if (mode === 'POLYGON') { obj.coordinates[0].splice(-1); - if (length < 2) { - setAlertModal({ - isOpen: true, + if (length < 3) { + // setAlertModal({ + // isOpen: true, + // title: '좌표 최소 개수', + // desc: '좌표를 세 개 점으로 이어주세요.' + // }); + props.setModal({ title: '좌표 최소 개수', - desc: '좌표를 세 개 점으로 이어주세요.' + desc: <>좌표를 세 개 점으로 이어주세요., + isOpen: true }); handlerRemoveError(obj.id); + return; } } const data = { @@ -282,20 +294,7 @@ export const LaancDrawControl = props => { alert('에러 발생'); } - props.handlerCoordinates(areaInfo); - setIsDrawDone(true); - - const viewCoordObj = drawObj - .getAll() - .features.filter(o => o.properties.id !== 'BUFFER'); - - props.setViewCoordObj(viewCoordObj); - - if (viewCoordObj.length > 19) { - props.handlerAddChange('overAdd', true); - } else { - props.handlerAddChange('isViewAdd', true); - } + handlerSaveData(areaInfo); }; // 비가시권 검사 @@ -417,6 +416,25 @@ export const LaancDrawControl = props => { props.setViewCoordObj(viewCoordObj); }; + // 정상 좌표 처리 + const handlerSaveData = areaInfo => { + console.log('ok!!!'); + props.handlerCoordinates(areaInfo); + setIsDrawDone(true); + + const viewCoordObj = drawObj + .getAll() + .features.filter(o => o.properties.id !== 'BUFFER'); + + props.setViewCoordObj(viewCoordObj); + + if (viewCoordObj.length > 19) { + props.handlerAddChange('overAdd', true); + } else { + props.handlerAddChange('isViewAdd', true); + } + }; + // areaInfo 셋팅 const handlerSettingAreaInfo = data => { if (!data.coord || !data.mode) {