state.laancState);
+ const { drawType, isClickAdd } = useSelector(state => state.laancState);
// mapbox 기본 onClick 함수 저장
const originClickRef = useRef(null);
@@ -49,9 +55,7 @@ export default function LaancDrawControl(props) {
useEffect(() => {
if (drawType === 'DONE') {
if (number !== 0) {
- const obj = drawObj
- .getAll()
- .features.filter(o => o.properties.id !== 'BUFFER');
+ const obj = getDrawFeatures(drawObj);
// 구역 생성 후 바로 directMode
if (obj.length > 0) {
@@ -379,7 +383,7 @@ export default function LaancDrawControl(props) {
handlerRemoveError(id);
return;
} else {
- props.handlerSaveCheck(true);
+ props.handlerCheckSavable(true);
}
// 비가시권 체크
@@ -423,7 +427,7 @@ export default function LaancDrawControl(props) {
handlerRemoveError(id);
return;
} else {
- props.handlerSaveCheck(true);
+ props.handlerCheckSavable(true);
return areaInfo;
}
};
@@ -483,7 +487,7 @@ export default function LaancDrawControl(props) {
if (!isRemain) {
dispatch(clientChangeDrawType('RESET'));
- props.handlerSaveCheck(false);
+ props.handlerCheckSavable(false);
} else {
dispatch(clientChangeDrawType('DONE'));
}
@@ -507,7 +511,7 @@ export default function LaancDrawControl(props) {
props.setViewCoordObj(viewCoordObj);
// 계속 20개 미만이라 overAdd false처리
- props.handlerAddChange('overAdd', false);
+ dispatch(clientIsOverAdd(false));
};
/**
@@ -518,15 +522,13 @@ export default function LaancDrawControl(props) {
props.handlerCoordinates(areaInfo);
setIsDrawDone(true);
- const viewCoordObj = drawObj
- .getAll()
- .features.filter(o => o.properties.id !== 'BUFFER' && o.properties.id);
+ const viewCoordObj = getDrawFeatures(drawObj);
props.setViewCoordObj(viewCoordObj);
if (viewCoordObj.length > 19) {
- props.handlerAddChange('overAdd', true);
+ dispatch(clientIsOverAdd(true));
} else {
- props.handlerAddChange('isViewAdd', true);
+ dispatch(clientIsViewAdd(true));
}
};
@@ -765,9 +767,7 @@ export default function LaancDrawControl(props) {
}
}
});
- const viewCoordObj = drawObj
- .getAll()
- .features.filter(o => o.properties.id !== 'BUFFER');
+ const viewCoordObj = getDrawFeatures(drawObj);
props.setViewCoordObj(viewCoordObj);
}
}
@@ -811,13 +811,14 @@ export default function LaancDrawControl(props) {
return;
}
- if (!props.addData.isAddable) {
+ // if (!props.addData.isAddable) {
+ if (!isClickAdd) {
// 추가 상태가 아닐 때
drawObj.deleteAll();
handlerRemoveAllMarker();
props.setViewCoordObj([]);
- props.handlerSaveCheck(false);
+ props.handlerCheckSavable(false);
props.handlerInitCoordinates();
}
@@ -830,14 +831,12 @@ export default function LaancDrawControl(props) {
* 초기화
*/
const handlerResetMode = () => {
- props.handlerAddChange('isAddable', false);
- props.handlerAddChange('isViewAdd', false);
- props.handlerAddChange('overAdd', false);
+ dispatch(clientInitAddButton());
drawObj.deleteAll();
handlerRemoveAllMarker();
props.setViewCoordObj([]);
- props.handlerSaveCheck(false);
+ props.handlerCheckSavable(false);
drawObj.changeMode('simple_select');
};
diff --git a/src/components/laanc/map/LaancMapModal.js b/src/components/laanc/map/LaancMapModal.js
index 9d583d1c..b2e16d1a 100644
--- a/src/components/laanc/map/LaancMapModal.js
+++ b/src/components/laanc/map/LaancMapModal.js
@@ -13,6 +13,7 @@ import {
clientAltitudeData,
clientChangeDrawType,
clientControlLaancModal,
+ clientIsClickAdd,
clientSaveAreaCoordinateList,
clientSaveAreaDetailList
} from '@src/redux/features/laanc/laancSlice';
@@ -21,20 +22,24 @@ import { openModal } from '@src/redux/features/comn/message/messageSlice';
const LaancDrawModal = lazy(() => import('./LaancDrawModal'));
const LaancMapWeather = lazy(() => import('./LaancMapWeather'));
-export default function LaancMapModal({
- drawObj,
- mapContainer,
- weather,
- areaCoordList
-}) {
+export default function LaancMapModal({ drawObj, mapContainer, weather }) {
const dispatch = useDispatch();
- const { drawType, isOpenModal } = useSelector(state => state.laancState);
+
+ // Laanc state
+ const {
+ drawType,
+ isOpenModal,
+ areaCoordList,
+ isClickAdd,
+ isOverAdd,
+ isViewAdd
+ } = useSelector(state => state.laancState);
// 저장된 비행구역 데이터
const [saveData, setSaveData] = useState();
// 비행구역 저장 가능 여부
- const [isSaveable, setIsSaveable] = useState(false);
+ const [isSavable, setIsSavable] = useState(false);
// 비행구역 고도
const [saveElev, setSaveElev] = useState([]);
@@ -53,36 +58,17 @@ export default function LaancMapModal({
* 비행구역 저장 가능 유무 체크
* @param {boolean} save 비행구역 저장 가능 유무
*/
- const handlerSaveCheck = save => {
- setIsSaveable(save);
+ const handlerCheckSavable = save => {
+ setIsSavable(save);
};
- // 비행구역 추가 가능 여부 판단
- const [addData, setAddData] = useState({
- isAddable: false,
- isViewAdd: false,
- overAdd: false
- });
-
// 비행구역 추가 버튼 클릭 시
const handlerAddClick = () => {
- if (!addData.isAddable || !addData.overAdd) {
- handlerAddChange('isAddable', true);
+ if (!isClickAdd || !isOverAdd) {
+ dispatch(clientIsClickAdd(true));
}
};
- /**
- * 비행구역 추가 관련 상태 변경
- * @param {string} key addData의 key
- * @param {boolean} val addData의 value
- */
- const handlerAddChange = (key, val) => {
- setAddData(prev => ({
- ...prev,
- [key]: val
- }));
- };
-
/**
* 비행구역 고도 저장
* @param {number} elev 비행고도
@@ -176,15 +162,13 @@ export default function LaancMapModal({
@@ -193,7 +177,7 @@ export default function LaancMapModal({
- {addData.isViewAdd ? (
+ {isViewAdd ? (
) : null}
- {addData.isViewAdd && weather[0]?.coordList[0].lat != 0 ? (
+ {isViewAdd && weather[0]?.coordList[0].lat != 0 ? (
@@ -248,7 +232,7 @@ export default function LaancMapModal({