<iframe src="https://developers.devsite.google/frame/maps/documentation/javascript/reference/3.65/elevation_c45d1befd8e9974b25e7068832ca19e5323c8461eff265c493ac4a1e57140477.frame" class="framebox inherit-locale redirect-iframe" allow="clipboard-write https://developers.devsite.google" allowfullscreen is-upgraded></iframe>

## [ElevationService](https://developers.google.com/maps/documentation/javascript/reference/3.65/elevation.md.txt#ElevationService)
class


class
`google.maps.ElevationService`

library `"elevation"`

Defines a service class that talks directly to Google servers for requesting elevation data.

```javascript
const {ElevationService} = await google.maps.importLibrary("elevation");
```

| ### Constructor ||
|---|---|
| `ElevationService` | `ElevationService()` **Parameters:** None Creates a new instance of a `ElevationService` that sends elevation queries to Google servers. |

| ### Methods ||
|---|---|
| `getElevationAlongPath` | `getElevationAlongPath(request[, callback])` **Parameters:** - `request: PathElevationRequest` - `callback: function(Array<ElevationResult> optional, ElevationStatus): void optional` **Return Value:** `Promise<PathElevationResponse>` Makes an elevation request along a path, where the elevation data are returned as distance-based samples along that path. |
| `getElevationForLocations` | `getElevationForLocations(request[, callback])` **Parameters:** - `request: LocationElevationRequest` - `callback: function(Array<ElevationResult> optional, ElevationStatus): void optional` **Return Value:** `Promise<LocationElevationResponse>` Makes an elevation request for a list of discrete locations. |

## [LocationElevationRequest](https://developers.google.com/maps/documentation/javascript/reference/3.65/elevation.md.txt#LocationElevationRequest)
interface


interface
`google.maps.LocationElevationRequest`

An elevation request sent by the `ElevationService` containing the list of discrete coordinates (`LatLng`s) for which to return elevation data.

| ### Properties ||
|---|---|
| `locations` optional | **Type:** `Array<LatLng|LatLngLiteral> optional` The discrete locations for which to retrieve elevations. |

## [LocationElevationResponse](https://developers.google.com/maps/documentation/javascript/reference/3.65/elevation.md.txt#LocationElevationResponse)
interface


interface
`google.maps.LocationElevationResponse`

An elevation response returned by the `ElevationService` containing the list of `ElevationResult`s matching the locations of the `LocationElevationRequest`.

| ### Properties ||
|---|---|
| `results` | **Type:** `Array<ElevationResult>` The list of `ElevationResult`s matching the locations of the `LocationElevationRequest`. |

## [PathElevationRequest](https://developers.google.com/maps/documentation/javascript/reference/3.65/elevation.md.txt#PathElevationRequest)
interface


interface
`google.maps.PathElevationRequest`

An elevation query sent by the `ElevationService` containing the path along which to return sampled data. This request defines a continuous path along the earth along which elevation samples should be taken at evenly-spaced distances. All paths from vertex to vertex use segments of the great circle between those two points.

| ### Properties ||
|---|---|
| `samples` | **Type:** `number` Required. The number of equidistant points along the given path for which to retrieve elevation data, including the endpoints. The number of samples must be a value between 2 and 512 inclusive. |
| `path` optional | **Type:** `Array<LatLng|LatLngLiteral> optional` The path along which to collect elevation values. |

## [PathElevationResponse](https://developers.google.com/maps/documentation/javascript/reference/3.65/elevation.md.txt#PathElevationResponse)
interface


interface
`google.maps.PathElevationResponse`

An elevation response returned by the `ElevationService` containing the list of `ElevationResult`s evenly-spaced along the path of the `PathElevationRequest`.

| ### Properties ||
|---|---|
| `results` | **Type:** `Array<ElevationResult>` The list of `ElevationResult`s matching the samples of the `PathElevationRequest`. |

## [ElevationResult](https://developers.google.com/maps/documentation/javascript/reference/3.65/elevation.md.txt#ElevationResult)
interface


interface
`google.maps.ElevationResult`

The result of an `ElevationService` request, consisting of the set of elevation coordinates and their elevation values. Note that a single request may produce multiple `ElevationResult`s.

| ### Properties ||
|---|---|
| `elevation` | **Type:** `number` The elevation of this point on Earth, in meters above sea level. |
| `resolution` | **Type:** `number` The distance, in meters, between sample points from which the elevation was interpolated. This property will be missing if the resolution is not known. Note that elevation data becomes more coarse (larger `resolution` values) when multiple points are passed. To obtain the most accurate elevation value for a point, it should be queried independently. |
| `location` optional | **Type:** `LatLng optional` The location of this elevation result. |

## [ElevationStatus](https://developers.google.com/maps/documentation/javascript/reference/3.65/elevation.md.txt#ElevationStatus)
constants


constants
`google.maps.ElevationStatus`

library `"elevation"`

The status returned by the `ElevationService` upon completion of an elevation request. Specify these by value, or by using the constant's name. For example, `'OK'` or `google.maps.ElevationStatus.OK`.

These constants are also usable as strings. In TypeScript, the string literals are defined by the `ElevationStatusString` type.

```javascript
const {ElevationStatus} = await google.maps.importLibrary("elevation");
```

| ### Constants ||
|---|---|
| `INVALID_REQUEST` | The request was invalid. |
| `OK` | The request did not encounter any errors. |
| `OVER_QUERY_LIMIT` | The webpage has gone over the requests limit in too short a period of time. |
| `REQUEST_DENIED` | The webpage is not allowed to use the elevation service. |
| `UNKNOWN_ERROR` | The elevation request could not be successfully processed, yet the exact reason for the failure is not known. |