Browse Source

비행계획서 지도(디폴트 최종)

feature/auth
sanguu 2 years ago
parent
commit
b2651f24c9
  1. 36
      src/components/basis/flight/plan/FlightPlanAreaMap.js

36
src/components/basis/flight/plan/FlightPlanAreaMap.js

@ -15,7 +15,6 @@ const FlightPlanAreaMap = (props) => {
const dispatch = useDispatch();
const naver = window.naver;
const airArea = props.airArea;
const isFlightDone = props.isFlightDone;
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(() => {
NaverMapInit();
}, []);
},[]);
useEffect(() => {
setIsMapLoad(true);
@ -38,22 +38,24 @@ 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){
if(areaCoordList){
if(areaCoordList[0].bufferZone>=0 && areaCoordList[0].bufferZone <2000){
bufferzoom.bufferzoom =13;
}
else if(areaCoordList[0].bufferZone>=2000 && areaCoordList[0].bufferZone <5000){
@ -66,13 +68,10 @@ const FlightPlanAreaMap = (props) => {
bufferzoom.bufferzoom =10;
}
}
console.log("bufferzoom>>",bufferzoom);
console.log(center);
const mapOptions2 = {
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,7 +79,7 @@ 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 => {
@ -142,7 +141,6 @@ const FlightPlanAreaMap = (props) => {
handleCoordinates={handleCoordinates}
handleInitCoordinates={handleInitCoordinates}
handleConfirm={props.handleConfirm}
isFlightDone={isFlightDone}
/> : null}
{/* <Button.Ripple
@ -156,7 +154,6 @@ const FlightPlanAreaMap = (props) => {
color='primary'
className='area-button'
onClick={e => handlerDrawType('RESET')}
{...(isFlightDone)? {disabled:true} : {} }
>
초기화
</Button.Ripple>
@ -173,7 +170,6 @@ const FlightPlanAreaMap = (props) => {
className='mr-1'
color='primary'
onClick={e => handlerDrawType('LINE')}
{...(isFlightDone)? {disabled:true} : {} }
>
WayPoint
</Button.Ripple>
@ -181,14 +177,12 @@ const FlightPlanAreaMap = (props) => {
className='mr-1'
color='primary'
onClick={e => handlerDrawType('CIRCLE')}
{...(isFlightDone)? {disabled:true} : {} }
>
Circle
</Button.Ripple>
<Button.Ripple
color='primary'
onClick={e => handlerDrawType('POLYGON')}
{...(isFlightDone)? {disabled:true} : {} }
>
Polygon
</Button.Ripple>

Loading…
Cancel
Save