按实际返回情况修改人员定位点位显示
parent
0f9d4c3fb0
commit
ffacaf7258
|
|
@ -1,7 +1,7 @@
|
||||||
import { useWebSocket } from "ahooks";
|
import { useWebSocket } from "ahooks";
|
||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import edgeQHD from "./edge/qhd.js";
|
import edgeQHD from "./edge/qhd.js";
|
||||||
import { filterNull, isPointWithinTheArea } from "./utils";
|
import { isPointWithinTheArea } from "./utils";
|
||||||
|
|
||||||
export default function usePeoplePosition(mapMethods, currentBranchOffice, onPeopleChange) {
|
export default function usePeoplePosition(mapMethods, currentBranchOffice, onPeopleChange) {
|
||||||
const markType = "peoplePosition";
|
const markType = "peoplePosition";
|
||||||
|
|
@ -16,16 +16,17 @@ export default function usePeoplePosition(mapMethods, currentBranchOffice, onPeo
|
||||||
|
|
||||||
const onMessage = async (message) => {
|
const onMessage = async (message) => {
|
||||||
const data = JSON.parse(message.data);
|
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++) {
|
for (let i = 0; i < peopleList.length; i++) {
|
||||||
const item = peopleList[i];
|
const item = peopleList[i];
|
||||||
if (!item)
|
const location = JSON.parse(item.locationRawJson).position;
|
||||||
|
if (!item || !location || !location.lon || !location.lat)
|
||||||
continue;
|
continue;
|
||||||
const index = points.current.findIndex(
|
const index = points.current.findIndex(
|
||||||
item1 => item1.id.toString() === (item.terminalNo || item.staffNo).toString(),
|
item1 => item1.id.toString() === (item.terminalNo || item.staffNo).toString(),
|
||||||
);
|
);
|
||||||
const x = item.lon;
|
const x = location.lon;
|
||||||
const y = item.lat;
|
const y = location.lat;
|
||||||
const pointColor = isPointWithinTheArea(edgeQHD(), x, y);
|
const pointColor = isPointWithinTheArea(edgeQHD(), x, y);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
points.current[index].x = x;
|
points.current[index].x = x;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue