diff --git a/src/pages/Container/Map/js/usePeoplePosition.js b/src/pages/Container/Map/js/usePeoplePosition.js index 5f16a52..4ecf89c 100644 --- a/src/pages/Container/Map/js/usePeoplePosition.js +++ b/src/pages/Container/Map/js/usePeoplePosition.js @@ -1,7 +1,7 @@ import { useWebSocket } from "ahooks"; import { useRef } from "react"; import edgeQHD from "./edge/qhd.js"; -import { filterNull, isPointWithinTheArea } from "./utils"; +import { isPointWithinTheArea } from "./utils"; export default function usePeoplePosition(mapMethods, currentBranchOffice, onPeopleChange) { const markType = "peoplePosition"; @@ -16,16 +16,17 @@ export default function usePeoplePosition(mapMethods, currentBranchOffice, onPeo const onMessage = async (message) => { const data = JSON.parse(message.data); - const peopleList = filterNull(Array.isArray(data) ? data : [data]); + const peopleList = Array.isArray(data) ? data : [data]; for (let i = 0; i < peopleList.length; i++) { const item = peopleList[i]; - if (!item) + const location = JSON.parse(item.locationRawJson).position; + if (!item || !location || !location.lon || !location.lat) continue; const index = points.current.findIndex( item1 => item1.id.toString() === (item.terminalNo || item.staffNo).toString(), ); - const x = item.lon; - const y = item.lat; + const x = location.lon; + const y = location.lat; const pointColor = isPointWithinTheArea(edgeQHD(), x, y); if (index !== -1) { points.current[index].x = x;