按实际返回情况修改人员定位点位显示
parent
0f9d4c3fb0
commit
ffacaf7258
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue