|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
import { useEffect } from 'react'; |
|
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
|
import { useDispatch, useSelector } from 'react-redux'; |
|
|
|
|
import { useHistory } from 'react-router-dom'; |
|
|
|
|
import { Button, ButtonGroup, CustomInput } from 'reactstrap'; |
|
|
|
|
import * as Actions from '../../../modules/menu/actions/menuAction'; |
|
|
|
|
import { |
|
|
|
|
areaClickAction, |
|
|
|
|
flightAreaClickAction, |
|
|
|
|
mapTypeChangeAction |
|
|
|
|
} from '../../../modules/control/map/actions/controlMapActions'; |
|
|
|
|
import geoJson from '../../../components/map/geojson/airArea.json'; |
|
|
|
@ -14,6 +15,8 @@ import gimPoGrid from '../../../components/map/geojson/airportAirArea.json';
|
|
|
|
|
// 김포 선형 공역
|
|
|
|
|
import flatGimpo from '../../../components/map/geojson/flatGimpoAirportAirArea.json'; |
|
|
|
|
|
|
|
|
|
import mapboxgl from 'mapbox-gl'; |
|
|
|
|
|
|
|
|
|
const ControlSetting = props => { |
|
|
|
|
const dispatch = useDispatch(); |
|
|
|
|
const history = useHistory(); |
|
|
|
@ -21,6 +24,9 @@ const ControlSetting = props => {
|
|
|
|
|
// 지도, 지도타입, 공역 타입 컨트롤
|
|
|
|
|
const mapControl = useSelector(state => state.controlMapReducer); |
|
|
|
|
|
|
|
|
|
// 이착륙장 마커
|
|
|
|
|
const [markerArr, setMarkerArr] = useState([]); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (mapControl.map) { |
|
|
|
|
const source = mapControl.map.getSource('maine'); |
|
|
|
@ -70,6 +76,29 @@ const ControlSetting = props => {
|
|
|
|
|
i => i.geometry.type === 'Polygon' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 이착륙장 마커 컨트롤
|
|
|
|
|
const firstMarker = mapControl.map._markers.filter(i => i?.properties); |
|
|
|
|
const pointArr = arrGeoJson.filter(i => i.geometry.type === 'Point'); |
|
|
|
|
|
|
|
|
|
if (firstMarker.length > 0 && !mapControl.area0005) |
|
|
|
|
firstMarker.map(m => m.remove()); |
|
|
|
|
|
|
|
|
|
if (mapControl.area0005) { |
|
|
|
|
if (markerArr.length === 0) { |
|
|
|
|
const markers = createFlightMarker(pointArr); |
|
|
|
|
|
|
|
|
|
setMarkerArr(markers); |
|
|
|
|
dispatch(flightAreaClickAction(markers)); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (markerArr.length > 0) { |
|
|
|
|
markerArr.map(m => m.remove()); |
|
|
|
|
|
|
|
|
|
setMarkerArr([]); |
|
|
|
|
dispatch(flightAreaClickAction(null)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
source.setData({ ...useGeoJson }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -83,6 +112,18 @@ const ControlSetting = props => {
|
|
|
|
|
mapControl.area0006 |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
// 이착륙장 마커 생성
|
|
|
|
|
const createFlightMarker = geojson => { |
|
|
|
|
const markers = geojson.map(i => { |
|
|
|
|
const marker = new mapboxgl.Marker() |
|
|
|
|
.setLngLat(i.geometry.coordinates) |
|
|
|
|
.addTo(mapControl.map); |
|
|
|
|
marker.properties = i.properties; |
|
|
|
|
return marker; |
|
|
|
|
}); |
|
|
|
|
return markers; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 지도 유형 변경
|
|
|
|
|
const handlerMapType = val => { |
|
|
|
|
if (val === mapControl.mapType) return; |
|
|
|
|