Skip to content

Commit e1b3a7e

Browse files
committed
feat(hooks): add max zoom hook
1 parent be9d081 commit e1b3a7e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/hooks/max-zoom.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {useMemo} from 'react';
2+
3+
import useGoogleMap from './map-instance';
4+
5+
/**
6+
* Hook to get Max Zoom Service instance
7+
*/
8+
const useMaxZoomService = (): google.maps.MaxZoomService | null => {
9+
const {map} = useGoogleMap();
10+
11+
// Creates a Max Zoom Service instance
12+
const maxZoomService =
13+
useMemo<google.maps.MaxZoomService | null>(() => {
14+
// Wait for map to be initialized
15+
if (!map) {
16+
return null;
17+
}
18+
19+
return new google.maps.MaxZoomService();
20+
}, [map]);
21+
22+
return maxZoomService;
23+
};
24+
25+
export default useMaxZoomService;

0 commit comments

Comments
 (0)