React hook to use the Elevation Service in any component.
import React, {useEffect} from 'react';
import {useElevationService} from '@ubilabs/google-maps-react-hooks';
const MyComponent = () => {
const elevator = useElevationService();
const location = /** google.maps.LatLng */;
useEffect(() => {
elevator?.getElevationForLocations(
{locations: [location]},
(results: google.maps.ElevationResult[]) => {
// Do something with results
}
);
}, [location]);
return (...);
};
Returns a Elevation Service
instance to use directly.
google.maps.ElevationService