Browse Source

map 거리측정 초기설정

master
김장현 2 months ago
parent
commit
0515765ecd
  1. 4
      src/components/map/MapControl.js
  2. 12
      src/components/map/mapbox/MapBoxMap.js
  3. 50
      src/containers/flight/OperationApprovalsContainer.js
  4. 14
      src/utility/MapUtils.js

4
src/components/map/MapControl.js

@ -1,5 +1,5 @@
import MapBoxMap from './mapbox/MapBoxMap'; import MapBoxMap from './mapbox/MapBoxMap';
export const MapControl = props => { export const MapControl = ({ handlerDrawObjInit }) => {
return <MapBoxMap />; return <MapBoxMap handlerDrawObjInit={handlerDrawObj} />;
}; };

12
src/components/map/mapbox/MapBoxMap.js

@ -19,14 +19,13 @@ import 'mapbox-gl/dist/mapbox-gl.css';
import { MAPBOX_TOKEN } from '../../../configs/constants'; import { MAPBOX_TOKEN } from '../../../configs/constants';
import mapboxgl from 'mapbox-gl'; import mapboxgl from 'mapbox-gl';
import MapboxLanguage from '@mapbox/mapbox-gl-language'; import MapboxLanguage from '@mapbox/mapbox-gl-language';
import threebox from 'threebox-plugin';
import { DronToast } from './dron/DronToast'; import { DronToast } from './dron/DronToast';
import { DronMarker } from './dron/DronMarker'; import { DronMarker } from './dron/DronMarker';
import { DronPlan } from './dron/DronPlan'; import { DronPlan } from './dron/DronPlan';
import FeatureAirZone from './feature/FeatureAirZone'; import FeatureAirZone from './feature/FeatureAirZone';
import threebox from 'threebox-plugin';
// v월드 공역 // v월드 공역
import { airArea } from '../geojson/_AirArea'; import { airArea } from '../geojson/_AirArea';
@ -38,7 +37,7 @@ import gimPoGrid from '../../../components/map/geojson/airportAirArea.json';
import flatGimpo from '../../map/geojson/flatGimpoAirportAirArea.json'; import flatGimpo from '../../map/geojson/flatGimpoAirportAirArea.json';
import { clientMapInit } from '@src/redux/features/control/map/mapSlice'; import { clientMapInit } from '@src/redux/features/control/map/mapSlice';
import axios from '@src/utility/customAxiosUtil'; import { getDraw } from '@src/utility/MapUtils';
let gridCoords = []; let gridCoords = [];
let altitudeMarker = []; let altitudeMarker = [];
@ -82,7 +81,7 @@ let linerAltitude = [
]; ];
let linerAltitudeMarker = []; let linerAltitudeMarker = [];
export default function MapBoxMap() { export default function MapBoxMap({ handlerDrawObjInit }) {
const dispatch = useDispatch(); const dispatch = useDispatch();
// 공역표출 타입 // 공역표출 타입
const mapState = useSelector(state => state.mapState); const mapState = useSelector(state => state.mapState);
@ -329,7 +328,8 @@ export default function MapBoxMap() {
map.addControl(language); map.addControl(language);
// 거리 축적 // 거리 축적
map.addControl(new mapboxgl.ScaleControl()); map.addControl(new mapboxgl.ScaleControl());
const drawObj = getDraw();
map.addControl(drawObj);
// 드래그 제한 2d // 드래그 제한 2d
// map.dragRotate.disable(); // map.dragRotate.disable();
@ -566,7 +566,7 @@ export default function MapBoxMap() {
setMapLoaded(true); setMapLoaded(true);
}); });
handlerDrawObjInit(drawObj);
setMapObject(map); setMapObject(map);
dispatch(clientMapInit(map)); dispatch(clientMapInit(map));
}; };

50
src/containers/flight/OperationApprovalsContainer.js

@ -8,11 +8,15 @@ import {
flightlayerWayPoint, flightlayerWayPoint,
flightlayerPolyline, flightlayerPolyline,
flightlayerPolygon, flightlayerPolygon,
flightlayerBuffer flightlayerBuffer,
handlerStartMode
} from '../../utility/MapUtils'; } from '../../utility/MapUtils';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import useMapType from '@hooks/useMapType'; import useMapType from '@hooks/useMapType';
import { clientSaveAreaCoordinateList } from '@src/redux/features/laanc/laancSlice'; import {
clientSaveAreaCoordinateList,
clientChangeDrawType
} from '@src/redux/features/laanc/laancSlice';
import { MapControl } from '../../components/map/MapControl'; import { MapControl } from '../../components/map/MapControl';
import { clientSetIsMapLoading } from '@src/redux/features/laanc/laancSlice'; import { clientSetIsMapLoading } from '@src/redux/features/laanc/laancSlice';
import { clientMapInit } from '@src/redux/features/control/map/mapSlice'; import { clientMapInit } from '@src/redux/features/control/map/mapSlice';
@ -45,7 +49,7 @@ export default function OperationApprovalsContainer({ mode }) {
const [selected, setSelected] = useState(null); const [selected, setSelected] = useState(null);
const [isMapLoading, setIsMapLoading] = useState(false); const [isMapLoading, setIsMapLoading] = useState(false);
// 비행구역 그리기 // 비행구역 그리기
const [drawObj, setDrawObj] = useState();
const [filter, setFilter] = useState(''); const [filter, setFilter] = useState('');
// 지도 // 지도
@ -410,6 +414,20 @@ export default function OperationApprovalsContainer({ mode }) {
}); });
}; };
const handlerDrawTypeChange = val => {
dispatch(clientChangeDrawType(val));
handlerStartMode(val, drawObj);
};
const handlerDrawObjInit = obj => {
setDrawObj(obj);
};
const handlerMapTypeChange = val => {
dispatch(clientChangeDrawType(''));
setMapType(val);
};
const handlerLogout = async () => { const handlerLogout = async () => {
const { payload } = await dispatch(setLogout()); const { payload } = await dispatch(setLogout());
@ -643,19 +661,19 @@ export default function OperationApprovalsContainer({ mode }) {
<ButtonGroup> <ButtonGroup>
<Button <Button
color={mapType === 'TERRAIN' ? 'primary' : ''} color={mapType === 'TERRAIN' ? 'primary' : ''}
onClick={e => setMapType('TERRAIN')} onClick={() => handlerMapTypeChange('TERRAIN')}
> >
지형지도 지형지도
</Button> </Button>
<Button <Button
color={mapType === 'SATELLITE' ? 'primary' : ''} color={mapType === 'SATELLITE' ? 'primary' : ''}
onClick={e => setMapType('SATELLITE')} onClick={() => handlerMapTypeChange('SATELLITE')}
> >
위성지도 위성지도
</Button> </Button>
<Button <Button
color={mapType === '2D' ? 'primary' : ''} color={mapType === '2D' ? 'primary' : ''}
onClick={e => setMapType('2D')} onClick={() => handlerMapTypeChange('2D')}
> >
2D 2D
</Button> </Button>
@ -666,15 +684,29 @@ export default function OperationApprovalsContainer({ mode }) {
<h4>거리측정</h4> <h4>거리측정</h4>
<div className='map-btn'> <div className='map-btn'>
<ButtonGroup> <ButtonGroup>
<Button primary>직선</Button> <Button
<Button primary>다각형</Button> color={drawType === 'LINE' ? 'primary' : ''}
onClick={() => {
handlerDrawTypeChange('LINE');
}}
>
직선
</Button>
<Button
color={drawType === 'POLYGON' ? 'primary' : ''}
onClick={() => {
handlerDrawTypeChange('POLYGON');
}}
>
다각형
</Button>
</ButtonGroup> </ButtonGroup>
</div> </div>
</div> </div>
</Card> </Card>
</div> </div>
</div> </div>
<MapControl /> <MapControl handlerDrawObjInit={handlerDrawObjInit} />
</div> </div>
<div className='left-menu'> <div className='left-menu'>
<h1 className='logo'> <h1 className='logo'>

14
src/utility/MapUtils.js

@ -566,3 +566,17 @@ export const getDraw = () =>
} }
] ]
}); });
/**
* 그리기모드 셋팅
* @param {'LINE' | 'POLYGON' | 'CIRCLE'} mode custom 타입
*/
export const handlerStartMode = (mode, drawObj) => {
if (mode === 'LINE') {
drawObj.changeMode('draw_line_string');
} else if (mode === 'POLYGON') {
drawObj.changeMode('draw_polygon');
} else if (mode === 'CIRCLE') {
drawObj.changeMode('draw_circle', { initialRadiusInKm: 100 / 1000 });
}
};

Loading…
Cancel
Save