File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,14 @@ function createPopupClass() {
13
13
14
14
Popup . prototype = Object . create ( google . maps . OverlayView . prototype ) ;
15
15
16
+ Popup . prototype . show = function ( ) {
17
+ this . containerDiv . style . visibility = 'visible' ;
18
+ } ;
19
+
20
+ Popup . prototype . hide = function ( ) {
21
+ this . containerDiv . style . visibility = 'hidden' ;
22
+ } ;
23
+
16
24
Popup . prototype . onAdd = function ( ) {
17
25
this . getPanes ( ) . floatPane . appendChild ( this . containerDiv ) ;
18
26
} ;
@@ -52,18 +60,28 @@ const CustomPopup = ({
52
60
passThroughMouseEvents
53
61
} ) => {
54
62
const containerEl = useRef ( null ) ;
63
+ const popoverRef = useRef ( null ) ;
64
+
55
65
useEffect ( ( ) => {
56
66
if ( map ) {
57
67
const pos = new google . maps . LatLng ( position . lat , position . lng ) ;
58
68
const Popup = createPopupClass ( ) ;
59
- new Popup ( {
69
+ popoverRef . current = new Popup ( {
60
70
position : pos ,
61
71
content : containerEl . current ,
62
72
map,
63
73
passThroughMouseEvents
64
74
} ) ;
65
75
}
66
76
} , [ map ] ) ;
77
+
78
+ useEffect ( ( ) => {
79
+ const popover = popoverRef . current ;
80
+ if ( popover ) {
81
+ visible ? popover . show ( ) : popover . hide ( ) ;
82
+ }
83
+ } , [ visible ] ) ;
84
+
67
85
return (
68
86
< div
69
87
className = { className }
You can’t perform that action at this time.
0 commit comments