-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathapp.tsx
46 lines (38 loc) · 1.15 KB
/
app.tsx
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React, {FunctionComponent, useState, useCallback} from 'react';
import {GoogleMapsProvider} from '@ubilabs/google-maps-react-hooks';
import MapCanvas from './components/map-canvas/map-canvas';
import MapMarkers from './components/map-markers/map-markers';
import {GOOGLE_MAPS_API_KEY} from '../constants';
import './main.module.css';
const mapOptions = {
center: {lat: 53.5582447, lng: 9.647645},
zoom: 6,
disableDefaultUI: true,
zoomControl: true,
zoomControlOptions: {
position: 3 // Right top
}
};
const App: FunctionComponent<Record<string, unknown>> = () => {
const [mapContainer, setMapContainer] = useState<HTMLDivElement | null>(null);
const mapRef = useCallback(
(node: React.SetStateAction<HTMLDivElement | null>) => {
node && setMapContainer(node);
},
[]
);
return (
<GoogleMapsProvider
googleMapsAPIKey={GOOGLE_MAPS_API_KEY}
mapContainer={mapContainer}
mapOptions={mapOptions}>
<React.StrictMode>
<div id="container">
<MapCanvas ref={mapRef} />
<MapMarkers />
</div>
</React.StrictMode>
</GoogleMapsProvider>
);
};
export default App;