File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -485,19 +485,22 @@ React hook to use the [Elevation Service](https://developers.google.com/maps/doc
485485
486486#### Usage
487487
488- ``` jsx
489- import React from ' react' ;
488+ ``` tsx
489+ import React , { useEffect } from ' react' ;
490490import {useElevationService } from ' @ubilabs/google-maps-react-hooks' ;
491491
492492const MyComponent = () => {
493493 const elevator = useElevationService ();
494-
495- elevator? .getElevationForLocations (
496- {locations: [location]},
497- (results : google .maps .ElevationResult []) => {
498- // Do something with results
499- }
500- );
494+ const location = /** google.maps.LatLng */ ;
495+
496+ useEffect (() => {
497+ elevator ?.getElevationForLocations (
498+ {locations: [location ]},
499+ (results : google .maps .ElevationResult []) => {
500+ // Do something with results
501+ }
502+ );
503+ }, [location ]);
501504
502505 return (... );
503506};
You can’t perform that action at this time.
0 commit comments