From b2651f24c9ab2a34ba3fd5e00f9a38f69899fa74 Mon Sep 17 00:00:00 2001 From: sanguu Date: Fri, 26 Aug 2022 17:09:31 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=ED=96=89=EA=B3=84=ED=9A=8D=EC=84=9C?= =?UTF-8?q?=20=EC=A7=80=EB=8F=84(=EB=94=94=ED=8F=B4=ED=8A=B8=20=EC=B5=9C?= =?UTF-8?q?=EC=A2=85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/flight/plan/FlightPlanAreaMap.js | 70 +++++++++---------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/src/components/basis/flight/plan/FlightPlanAreaMap.js b/src/components/basis/flight/plan/FlightPlanAreaMap.js index 4112baf5..04300b10 100644 --- a/src/components/basis/flight/plan/FlightPlanAreaMap.js +++ b/src/components/basis/flight/plan/FlightPlanAreaMap.js @@ -14,8 +14,7 @@ import { AREA_COORDINATE_LIST_SAVE } from '../../../../modules/basis/flight/acti const FlightPlanAreaMap = (props) => { const dispatch = useDispatch(); const naver = window.naver; - const airArea = props.airArea; - const isFlightDone = props.isFlightDone; + const airArea = props.airArea; const mapControl = useSelector(state => state.controlMapReducer); const { areaCoordList } = useSelector(state => state.flightState); @@ -24,9 +23,10 @@ const FlightPlanAreaMap = (props) => { const [mode, setMode] = useState(); const [mapAreaCoordList, setMapAreaCoordList] = useState(initFlightBas.initDetail.areaList); - useEffect(() => { + + useEffect(() => { NaverMapInit(); - }, []); + },[]); useEffect(() => { setIsMapLoad(true); @@ -38,41 +38,40 @@ const FlightPlanAreaMap = (props) => { }, [mapControl.drawType]); useEffect(() => { - // NaverMapInit(); + if(areaCoordList) { + if(areaCoordList[0].coordList[0].lat !== 0 && areaCoordList[0].coordList[0].lon !== 0){ + if(map) { + map.setCenter(new naver.maps.LatLng(areaCoordList[0].coordList[0].lat, areaCoordList[0].coordList[0].lon)) + } + } + } setMapAreaCoordList(areaCoordList) }, [areaCoordList]); - const ModeInit = () => { setMode(mapControl.drawType) } - + const NaverMapInit = () => { - const center = {}; const bufferzoom ={}; - if(areaCoordList) { - center.lat = areaCoordList[0].coordList[0].lat === 0 ? 37.520357 : areaCoordList[0].coordList[0].lat; - center.lon = areaCoordList[0].coordList[0].lon === 0 ? 126.610166 : areaCoordList[0].coordList[0].lon; - if(areaCoordList[0].bufferZone>=0 && areaCoordList[0].bufferZone<2000){ - bufferzoom.bufferzoom =13; - } - else if(areaCoordList[0].bufferZone>=2000 && areaCoordList[0].bufferZone <5000){ - bufferzoom.bufferzoom =12; - } - else if(areaCoordList[0].bufferZone>=5000 && areaCoordList[0].bufferZone <=9000){ - bufferzoom.bufferzoom =11; - } - else{ - bufferzoom.bufferzoom =10; - } - } - console.log("bufferzoom>>",bufferzoom); - console.log(center); - const mapOptions2 = { + if(areaCoordList){ + if(areaCoordList[0].bufferZone>=0 && areaCoordList[0].bufferZone <2000){ + bufferzoom.bufferzoom =13; + } + else if(areaCoordList[0].bufferZone>=2000 && areaCoordList[0].bufferZone <5000){ + bufferzoom.bufferzoom =12; + } + else if(areaCoordList[0].bufferZone>=5000 && areaCoordList[0].bufferZone <=9000){ + bufferzoom.bufferzoom =11; + } + else{ + bufferzoom.bufferzoom =10; + } + } + const mapOptions = { // center: new naver.maps.LatLng(36.56793936069445, 127.85101412107547), - center: new naver.maps.LatLng(center.lat, center.lon), - // zoom: 10, - zoom: bufferzoom.bufferzoom, + center: new naver.maps.LatLng(37.520357, 126.610166), + zoom: !areaCoordList ? 13 : bufferzoom.bufferzoom, zoomControl: true, mapTypeId: naver.maps.MapTypeId.NORMAL, zoomControlOptions: { @@ -80,9 +79,9 @@ const FlightPlanAreaMap = (props) => { style: naver.maps.ZoomControlStyle.SMALL } }; - setMap(new naver.maps.Map('map', mapOptions2)); + setMap(new naver.maps.Map('map', mapOptions)); } - + const handlerDrawType = val => { dispatch(drawTypeChangeAction(val)); }; @@ -142,7 +141,6 @@ const FlightPlanAreaMap = (props) => { handleCoordinates={handleCoordinates} handleInitCoordinates={handleInitCoordinates} handleConfirm={props.handleConfirm} - isFlightDone={isFlightDone} /> : null} {/* { handlerDrawType('RESET')} - {...(isFlightDone)? {disabled:true} : {} } + onClick={e => handlerDrawType('RESET')} > 초기화 @@ -173,7 +170,6 @@ const FlightPlanAreaMap = (props) => { className='mr-1' color='primary' onClick={e => handlerDrawType('LINE')} - {...(isFlightDone)? {disabled:true} : {} } > WayPoint @@ -181,14 +177,12 @@ const FlightPlanAreaMap = (props) => { className='mr-1' color='primary' onClick={e => handlerDrawType('CIRCLE')} - {...(isFlightDone)? {disabled:true} : {} } > Circle handlerDrawType('POLYGON')} - {...(isFlightDone)? {disabled:true} : {} } > Polygon