File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
src/frontend/src/Components Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ export default function MapWrapper({
84
84
const hoveredCamera = useRef ( ) ;
85
85
const hoveredEvent = useRef ( ) ;
86
86
const locationPinRef = useRef ( null ) ;
87
+ const cameraPopupRef = useRef ( null ) ;
87
88
88
89
// States
89
90
const [ layersOpen , setLayersOpen ] = useState ( false ) ;
@@ -414,6 +415,11 @@ export default function MapWrapper({
414
415
popup . current . getElement ( ) . style . top = '40px' ;
415
416
416
417
updateClickedCamera ( feature ) ;
418
+
419
+ if ( ! cameraPopupRef . current ) {
420
+ cameraPopupRef . current = popup ;
421
+ }
422
+
417
423
}
418
424
} else {
419
425
// if it wasn't a webcam icon, check if it was an event
@@ -753,7 +759,7 @@ export default function MapWrapper({
753
759
/>
754
760
< div id = "popup-content" className = "ol-popup-content" >
755
761
{ clickedCamera &&
756
- getCamPopup ( clickedCamera , updateClickedCamera , navigate )
762
+ getCamPopup ( clickedCamera , updateClickedCamera , navigate , cameraPopupRef )
757
763
}
758
764
759
765
{ clickedEvent &&
Original file line number Diff line number Diff line change @@ -43,13 +43,24 @@ function renderCamGroup(camFeature, setClickedCamera) {
43
43
return res ;
44
44
}
45
45
46
- export function getCamPopup ( camFeature , setClickedCamera , navigate ) {
46
+ export function getCamPopup ( camFeature , setClickedCamera , navigate , cameraPopupRef ) {
47
47
const rootCamData = camFeature . getProperties ( ) ;
48
48
49
49
const camData = ! rootCamData . groupIndex ? rootCamData : rootCamData . camGroup [ rootCamData . groupIndex ] ;
50
+
51
+ const handlePopupClick = ( e ) => {
52
+ if ( ! cameraPopupRef . current ) {
53
+ navigate ( `/cameras/${ camData . id } ` ) ;
54
+ }
55
+ else {
56
+ cameraPopupRef . current = null ;
57
+ return ;
58
+ }
59
+ } ;
60
+
50
61
return (
51
62
< div className = "popup popup--camera" >
52
- < div onClick = { ( ) => navigate ( `/cameras/ ${ camData . id } ` ) } >
63
+ < div onClick = { handlePopupClick } >
53
64
< div className = "popup__title" >
54
65
< p className = "bold name" > { camData . name } </ p >
55
66
< p className = "bold orientation" > { camData . orientation } </ p >
You can’t perform that action at this time.
0 commit comments