-
Notifications
You must be signed in to change notification settings - Fork 807
Expand file tree
/
Copy pathwithCustomOverlay.js
More file actions
32 lines (29 loc) · 942 Bytes
/
withCustomOverlay.js
File metadata and controls
32 lines (29 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { useState, Fragment } from 'react';
import Map from '../../src/index';
import CustomOverlay from '../../src/components/CustomOverlay';
import styles from './withCustomOverlay.module.css';
const WithCustomOverlay = (props) => {
const [showOverlay, setShowOverlay] = useState(true);
if (!props.loaded) return <div>Loading...</div>;
return (
<Fragment>
<button
className={styles.button}
onClick={() => setShowOverlay(!showOverlay)}
>
Toggle Popup
</button>
<Map google={props.google} className="map" zoom={14}>
<CustomOverlay
position={{ lat: 37.782551, lng: -122.425368 }}
visible={showOverlay}
className={styles.overlayContainer}
passThroughMouseEvents={true}
>
<div>Hi there. I'm a custom overlay.</div>
</CustomOverlay>
</Map>
</Fragment>
);
};
export default WithCustomOverlay;