sanguu(박상현) 2 years ago
parent
commit
c09776fcad
  1. 2
      src/App.js
  2. 33
      src/components/map/naver/dron/DronMarker.js

2
src/App.js

@ -1,6 +1,6 @@
// ** Router Import // ** Router Import
import Router from './router/Router'; import Router from './router/Router';
// if (process.env.NODE_ENV === 'production') console.log = function () {}; if (process.env.NODE_ENV === 'production') console.log = function () {};
const App = props => <Router />; const App = props => <Router />;
export default App; export default App;

33
src/components/map/naver/dron/DronMarker.js

@ -37,7 +37,7 @@ export const DronMarker = props => {
const { joinList } = useSelector(state => state.groupState); const { joinList } = useSelector(state => state.groupState);
const [arrMarkers, setArrMarkers] = useState([]); const [arrMarkers, setArrMarkers] = useState([]);
// const [arrInfos, setArrInfos] = useState([]); const [arrInfos, setArrInfos] = useState([]);
let naver = props.naver; let naver = props.naver;
let map = props.map; let map = props.map;
@ -95,6 +95,12 @@ export const DronMarker = props => {
); );
}, []); }, []);
useEffect(() => {
if (arrMarkers.length != 0) {
markerInfo(arrMarkers);
}
}, [arrMarkers]);
useEffect(() => { useEffect(() => {
markerInit(); markerInit();
}, [controlGpList]); }, [controlGpList]);
@ -133,28 +139,21 @@ export const DronMarker = props => {
//마커를 그린다. //마커를 그린다.
const addMarkers = (position, id, controlId, gps) => { const addMarkers = (position, id, controlId, gps) => {
const markerOption = {}; const markerOption = {};
console.log(gps, 'gps');
console.log(id, 'idntfNum');
if (id.substring(0, 2) === 'PA') { if (id.substring(0, 2) === 'PA') {
const pal = controlGroupAuthInfo?.find( const pal = controlGroupAuthInfo?.find(
prev => prev.idntfNum === gps.objectId prev => prev.idntfNum === gps.objectId
); );
console.log(pal, '등록된 식별장치');
if (pal) { if (pal) {
console.log('맞음');
markerOption.url = DronIcon; markerOption.url = DronIcon;
markerOption.type = 'DRONE'; markerOption.type = 'DRONE';
} else { } else {
console.log('아님');
if (user.authId === 'SUPER' || user.authId === 'ADMIN') { if (user.authId === 'SUPER' || user.authId === 'ADMIN') {
console.log('super, admin'); console.log('super, admin');
markerOption.url = FlightIcon; markerOption.url = FlightIcon;
markerOption.type = 'FLIGHT'; markerOption.type = 'FLIGHT';
} else { } else {
console.log('user');
const terminal = joinList?.find(prev => prev.trmnlId === gps.trmnlId); const terminal = joinList?.find(prev => prev.trmnlId === gps.trmnlId);
console.log(terminal, 'trmnlId 일치 있음');
if ( if (
terminal?.groupAuthCd === 'MASTER' || terminal?.groupAuthCd === 'MASTER' ||
terminal?.groupAuthCd === 'LEADER' terminal?.groupAuthCd === 'LEADER'
@ -309,6 +308,16 @@ export const DronMarker = props => {
const arrData = arrMarkers.filter(item => item.id != marker.id); const arrData = arrMarkers.filter(item => item.id != marker.id);
removeArrMarkers(arrData); removeArrMarkers(arrData);
dispatch(objectUnClickAction());
}
});
arrInfos.map(info => {
const isExists = controlGpList.find(item => item.objectId === info._id);
if (!isExists) {
removeInfos(info);
const arrData = arrInfos.filter(item => item.id != info._id);
removeArrInfos(arrData);
dispatch(objectUnClickAction()); dispatch(objectUnClickAction());
} }
}); });
@ -324,10 +333,10 @@ export const DronMarker = props => {
if (arrMarkers) { if (arrMarkers) {
const isExists = arrMarkers.find(ele => ele.id === item.objectId); const isExists = arrMarkers.find(ele => ele.id === item.objectId);
// const isInfos = arrInfos.find( info => info._id === item.objectId ) const isInfos = arrInfos.find(info => info._id === item.objectId);
if (isExists) { if (isExists) {
moveMarkers(isExists, position, item); moveMarkers(isExists, position, item);
// moveInfos(isInfos, position); moveInfos(isInfos, position);
} else { } else {
addMarkers(position, item.objectId, item.controlId, item); addMarkers(position, item.objectId, item.controlId, item);
} }
@ -447,9 +456,9 @@ export const DronMarker = props => {
setArrInfos(arrData); setArrInfos(arrData);
}; };
const markerInfo = () => { const markerInfo = arrMarkers => {
arrMarkers.forEach((marker, idx) => { arrMarkers.forEach((marker, idx) => {
// infoInit(marker, controlGpList[idx], idx); infoInit(marker, controlGpList[idx], idx);
if (controlGpList.length != 0) { if (controlGpList.length != 0) {
const info = new CustomOverlay({ const info = new CustomOverlay({

Loading…
Cancel
Save