diff --git a/src/pages/Container/Map/components/Header/index.js b/src/pages/Container/Map/components/Header/index.js index 2262c85..1bd94ef 100644 --- a/src/pages/Container/Map/components/Header/index.js +++ b/src/pages/Container/Map/components/Header/index.js @@ -16,11 +16,12 @@ const headerAnimation = { }; function Header() { - const { currentPort, currentBranchOffice, mapMethods, portArea, headerTitle, actions } = useContext(Context); + const { currentPort, currentBranchOffice, mapMethods, portArea, headerTitle, actions, closePopup } = useContext(Context); const isPortTitle = headerTitle === "秦港股份安全监管平台"; const onBack = () => { + closePopup(); sessionStorage.removeItem("mapCurrentBranchOfficeId"); if (!currentPort) { window.close(); diff --git a/src/pages/Container/Map/components/popup/components/BranchOffice.js b/src/pages/Container/Map/components/popup/components/BranchOffice.js index 145d593..d9d4421 100644 --- a/src/pages/Container/Map/components/popup/components/BranchOffice.js +++ b/src/pages/Container/Map/components/popup/components/BranchOffice.js @@ -42,7 +42,7 @@ const BranchOffice = ({ info, close, enter }) => {
地址:
- {info?.address} + {info?.addressBusiness}
diff --git a/src/pages/Container/Map/index.js b/src/pages/Container/Map/index.js index 5a1fbda..7f71a52 100644 --- a/src/pages/Container/Map/index.js +++ b/src/pages/Container/Map/index.js @@ -25,7 +25,7 @@ import "./index.less"; function Map(props) { const query = useGetUrlQuery(); - const { viewer, mapMethods, initMap, externalEntryPort } = useInitMap({ + const { viewer, mapMethods, initMap, externalEntryPort, closePopup } = useInitMap({ request: { getCorpInfoListAll: props.getCorpInfoListAll, }, @@ -108,8 +108,8 @@ function Map(props) { }, []); const providerValues = useMemo( - () => ({ viewer, mapMethods, ...state, actions }), - [viewer, mapMethods, state, actions], + () => ({ viewer, mapMethods, closePopup, ...state, actions }), + [viewer, mapMethods, closePopup, state, actions], ); return ( diff --git a/src/pages/Container/Map/js/initMap.js b/src/pages/Container/Map/js/initMap.js index fa0cc7a..29ddde4 100644 --- a/src/pages/Container/Map/js/initMap.js +++ b/src/pages/Container/Map/js/initMap.js @@ -14,6 +14,8 @@ export default function useInitMap(options) { mapMethods.current = mapMethodsValue; // 点位点击处理集合:替代原 PointClickEvent class 实例,负责弹窗和层级进入。 const pointClickEvent = usePointClickEvent(viewer, mapMethodsValue); + // Cesium 点击事件只在初始化时注册,必须始终使用首次创建的处理器,才能关闭其维护的 Popup 实例。 + const pointClickEventRef = useRef(pointClickEvent); // 获取当前 Cesium 实例,减少内部方法对 ref 结构的重复感知。 const getViewer = () => viewer.current; @@ -56,10 +58,10 @@ export default function useInitMap(options) { screenSpaceEventHandler.setInputAction((movement) => { const pick = getViewer().scene.pick(movement.position); if (Cesium.defined(pick) && pick.id?.id) { - pointClickEvent.pointClickEvent(pick.id); + pointClickEventRef.current.pointClickEvent(pick.id); } else { - pointClickEvent.closePopup(); + pointClickEventRef.current.closePopup(); } }, Cesium.ScreenSpaceEventType.LEFT_CLICK); }; @@ -143,7 +145,7 @@ export default function useInitMap(options) { if (!id || !name || !hasValidPosition) return false; - pointClickEvent.pointClickEvent({ + pointClickEventRef.current.pointClickEvent({ monitorItems: { data: { ...data, @@ -164,5 +166,6 @@ export default function useInitMap(options) { mapMethods, initMap, externalEntryPort, + closePopup: () => pointClickEventRef.current.closePopup(), }; }