File tree Expand file tree Collapse file tree 2 files changed +65
-1
lines changed
Expand file tree Collapse file tree 2 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -501,12 +501,49 @@ const MyComponent = () => {
501501};
502502` ` `
503503
504+ #### Return value
505+
504506Returns the [ ` DistanceMatrixService ` ](google.maps.DistanceMatrixService) class to use directly.
505507
506508` ` ` TypeScript
507509google .maps .DistanceMatrixService
508510` ` `
509511
512+ ### useMaxZoomService
513+
514+ React hook to use the [Maximum Zoom Imagery Service](https://developers.google.com/maps/documentation/javascript/maxzoom) in any component.
515+
516+ #### Usage
517+
518+ ` ` ` tsx
519+ import React , {useEffect } from ' react' ;
520+ import {useMaxZoomService } from ' @ubilabs/google-maps-react-hooks' ;
521+
522+ const MyComponent = () => {
523+ const maxZoomService = useMaxZoomService ();
524+ const location = /** google.maps.LatLng */ ;
525+
526+ useEffect (() => {
527+ maxZoomService ?.getMaxZoomAtLatLng (
528+ location ,
529+ (result : google .maps .MaxZoomResult ) => {
530+ // Do something with result
531+ }
532+ );
533+ }, [location ]);
534+
535+ return (... );
536+ };
537+ ` ` `
538+
539+ #### Return value
540+
541+ Returns the [ ` MaxZoomService ` ](google.maps.places.MaxZoomService) class to use directly.
542+
543+ ` ` ` TypeScript
544+ google .maps .places .MaxZoomService
545+ ` ` `
546+
510547### useElevationService
511548
512549React hook to use the [Elevation Service](https://developers.google.com/maps/documentation/javascript/elevation) in any component.
@@ -529,6 +566,9 @@ const MyComponent = () => {
529566 }
530567 );
531568 }, [location ]);
569+
570+ return (... );
571+ };
532572` ` `
533573
534574#### Return value
@@ -539,7 +579,6 @@ Returns the [`ElevationService`](google.maps.places.ElevationService) class to u
539579google .maps .places .ElevationService
540580` ` `
541581
542-
543582## Publish (only for maintainers)
544583
545584` npm publish -- access public `
Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments