|
|
|
@ -2,6 +2,7 @@ import { useEffect, useRef, useState, lazy, Suspense } from 'react';
|
|
|
|
|
import { useDispatch, useSelector } from '@src/redux/store'; |
|
|
|
|
import { |
|
|
|
|
CalculateDistance, |
|
|
|
|
getDrawFeatures, |
|
|
|
|
handlerCreateGroupMarker, |
|
|
|
|
handlerCreateOneMarker, |
|
|
|
|
handlerGetMidPoint, |
|
|
|
@ -9,7 +10,12 @@ import {
|
|
|
|
|
handlerRemoveGroupMarker, |
|
|
|
|
handlerReturnMode |
|
|
|
|
} from '../../../utility/MapUtils'; |
|
|
|
|
import { clientChangeDrawType } from '@src/redux/features/laanc/laancSlice'; |
|
|
|
|
import { |
|
|
|
|
clientChangeDrawType, |
|
|
|
|
clientInitAddButton, |
|
|
|
|
clientIsOverAdd, |
|
|
|
|
clientIsViewAdd |
|
|
|
|
} from '@src/redux/features/laanc/laancSlice'; |
|
|
|
|
import MapboxDraw from '@mapbox/mapbox-gl-draw'; |
|
|
|
|
import { |
|
|
|
|
CircleMode, |
|
|
|
@ -31,7 +37,7 @@ export default function LaancDrawControl(props) {
|
|
|
|
|
const mapObject = props.mapObject; |
|
|
|
|
|
|
|
|
|
// 비행구역 타입
|
|
|
|
|
const { drawType } = useSelector(state => 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'); |
|
|
|
|
}; |
|
|
|
|