We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be9d081 commit 2c2fe2cCopy full SHA for 2c2fe2c
src/hooks/elevation.ts
@@ -0,0 +1,25 @@
1
+import {useMemo} from 'react';
2
+
3
+import useGoogleMap from './map-instance';
4
5
+/**
6
+ * Hook to get Elevation Service instance
7
+ */
8
+const useElevation = (): google.maps.ElevationService | null => {
9
+ const {map} = useGoogleMap();
10
11
+ // Creates a Elevation Service instance
12
+ const elevationService =
13
+ useMemo<google.maps.ElevationService | null>(() => {
14
+ // Wait for map to be initialized
15
+ if (!map) {
16
+ return null;
17
+ }
18
19
+ return new google.maps.ElevationService();
20
+ }, [map]);
21
22
+ return elevationService;
23
+};
24
25
+export default useElevation;
0 commit comments