File tree 2 files changed +65
-1
lines changed
2 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -501,12 +501,49 @@ const MyComponent = () => {
501
501
};
502
502
` ` `
503
503
504
+ #### Return value
505
+
504
506
Returns the [ ` DistanceMatrixService ` ](google.maps.DistanceMatrixService) class to use directly.
505
507
506
508
` ` ` TypeScript
507
509
google .maps .DistanceMatrixService
508
510
` ` `
509
511
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
+
510
547
### useElevationService
511
548
512
549
React hook to use the [Elevation Service](https://developers.google.com/maps/documentation/javascript/elevation) in any component.
@@ -529,6 +566,9 @@ const MyComponent = () => {
529
566
}
530
567
);
531
568
}, [location ]);
569
+
570
+ return (... );
571
+ };
532
572
` ` `
533
573
534
574
#### Return value
@@ -539,7 +579,6 @@ Returns the [`ElevationService`](google.maps.places.ElevationService) class to u
539
579
google .maps .places .ElevationService
540
580
` ` `
541
581
542
-
543
582
## Publish (only for maintainers)
544
583
545
584
` 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