Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 839 Bytes

useElevationService.md

File metadata and controls

34 lines (25 loc) · 839 Bytes

useElevationService Hook

React hook to use the Elevation Service in any component.

Usage

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 (...);
};

Return value

Returns a Elevation Service instance to use directly.

google.maps.ElevationService