From 08471a29e9a038bbe14443086b5c2c22d65104eb Mon Sep 17 00:00:00 2001 From: sanguu Date: Thu, 25 Aug 2022 19:03:52 +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=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basis/flight/plan/FlightPlanAreaMap.js | 56 +++++++++++++------ 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/src/components/basis/flight/plan/FlightPlanAreaMap.js b/src/components/basis/flight/plan/FlightPlanAreaMap.js index 1c9736c..31fd619 100644 --- a/src/components/basis/flight/plan/FlightPlanAreaMap.js +++ b/src/components/basis/flight/plan/FlightPlanAreaMap.js @@ -24,40 +24,62 @@ const FlightPlanAreaMap = (props) => { const [mapAreaCoordList, setMapAreaCoordList] = useState(initFlightBas.initDetail.areaList); useEffect(() => { - NaverMapInit(); + NaverMapInit(); }, []); - + useEffect(() => { setIsMapLoad(true); }, [airArea]); + useEffect(() => { ModeInit(); }, [mapControl.drawType]); useEffect(() => { + // NaverMapInit(); setMapAreaCoordList(areaCoordList) }, [areaCoordList]); const ModeInit = () => { setMode(mapControl.drawType) - } - const NaverMapInit = () => { - const mapOptions = { - // center: new naver.maps.LatLng(36.56793936069445, 127.85101412107547), - center: new naver.maps.LatLng(37.520357, 126.610166), - // zoom: 10, - zoom: 15, - zoomControl: true, - mapTypeId: naver.maps.MapTypeId.NORMAL, - zoomControlOptions: { - position: naver.maps.Position.LEFT_CENTER, - style: naver.maps.ZoomControlStyle.SMALL - } - }; - setMap(new naver.maps.Map('map', mapOptions)); + console.log(areaCoordList); + 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 = { + // center: new naver.maps.LatLng(36.56793936069445, 127.85101412107547), + center: new naver.maps.LatLng(center.lat, center.lon), + // zoom: 10, + zoom: bufferzoom.bufferzoom, + zoomControl: true, + mapTypeId: naver.maps.MapTypeId.NORMAL, + zoomControlOptions: { + position: naver.maps.Position.LEFT_CENTER, + style: naver.maps.ZoomControlStyle.SMALL + } + }; + setMap(new naver.maps.Map('map', mapOptions2)); } const handlerDrawType = val => {