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

## [encoding](https://developers.google.com/maps/documentation/javascript/reference/3.63/geometry.md.txt#encoding)
class


`google.maps.geometry.encoding`
class

Utilities for polyline encoding and decoding.

Access by calling `const {encoding} = await google.maps.importLibrary("geometry")`.   
See [Libraries in the Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/libraries.md.txt).

| ### Static Methods ||
|---|---|
| `decodePath` | `decodePath(encodedPath)` **Parameters:** - `encodedPath`: `string` **Return Value:** `Array<LatLng>` Decodes an encoded path string into a sequence of LatLngs. |
| `encodePath` | `encodePath(path)` **Parameters:** - `path`: `Array<LatLng|LatLngLiteral>|MVCArray<LatLng|LatLngLiteral>` **Return Value:** `string` Encodes a sequence of LatLngs into an encoded path string. |

## [spherical](https://developers.google.com/maps/documentation/javascript/reference/3.63/geometry.md.txt#spherical)
class


`google.maps.geometry.spherical`
class

Utility functions for computing geodesic angles, distances and areas. The default radius is Earth's radius of 6378137 meters.

Access by calling `const {spherical} = await google.maps.importLibrary("geometry")`.   
See [Libraries in the Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/libraries.md.txt).

| ### Static Methods ||
|---|---|
| `computeArea` | `computeArea(path[, radiusOfSphere])` **Parameters:** - `path`: `Array<LatLng|LatLngLiteral>|MVCArray<LatLng|LatLngLiteral>|Circle|CircleLiteral|LatLngBounds|LatLngBoundsLiteral` - `radiusOfSphere`: `number optional` **Return Value:** `number` Returns the unsigned area of a closed path, in the range \[0, 2×pi×radius²\]. The computed area uses the same units as the radius. The `radiusOfSphere` defaults to the Earth's radius in meters, in which case the area is in square meters. Passing a `Circle` requires the `radius` to be set to a non-negative value. Additionally, the Circle must not cover more than 100% of the sphere. And when passing a `LatLngBounds`, the southern LatLng cannot be more north than the northern LatLng. |
| `computeDistanceBetween` | `computeDistanceBetween(from, to[, radius])` **Parameters:** - `from`: `LatLng|LatLngLiteral` - `to`: `LatLng|LatLngLiteral` - `radius`: `number optional` **Return Value:** `number` Returns the distance, in meters, between two LatLngs. You can optionally specify a custom radius. The radius defaults to the radius of the Earth. |
| `computeHeading` | `computeHeading(from, to)` **Parameters:** - `from`: `LatLng|LatLngLiteral` - `to`: `LatLng|LatLngLiteral` **Return Value:** `number` Returns the heading from one LatLng to another LatLng. Headings are expressed in degrees clockwise from North within the range \[-180,180). |
| `computeLength` | `computeLength(path[, radius])` **Parameters:** - `path`: `Array<LatLng|LatLngLiteral>|MVCArray<LatLng|LatLngLiteral>` - `radius`: `number optional` **Return Value:** `number` Returns the length of the given path. |
| `computeOffset` | `computeOffset(from, distance, heading[, radius])` **Parameters:** - `from`: `LatLng|LatLngLiteral` - `distance`: `number` - `heading`: `number` - `radius`: `number optional` **Return Value:** `LatLng` Returns the LatLng resulting from moving a distance from an origin in the specified heading (expressed in degrees clockwise from north). |
| `computeOffsetOrigin` | `computeOffsetOrigin(to, distance, heading[, radius])` **Parameters:** - `to`: `LatLng|LatLngLiteral` - `distance`: `number` - `heading`: `number` - `radius`: `number optional` **Return Value:** `LatLng|null` Returns the location of origin when provided with a LatLng destination, meters travelled and original heading. Headings are expressed in degrees clockwise from North. This function returns `null` when no solution is available. |
| `computeSignedArea` | `computeSignedArea(loop[, radius])` **Parameters:** - `loop`: `Array<LatLng|LatLngLiteral>|MVCArray<LatLng|LatLngLiteral>` - `radius`: `number optional` **Return Value:** `number` Returns the signed area of a closed path, where counterclockwise is positive, in the range \[-2×pi×radius², 2×pi×radius²\]. The computed area uses the same units as the radius. The radius defaults to the Earth's radius in meters, in which case the area is in square meters. The area is computed using the [parallel transport](https://wikipedia.org/wiki/Parallel_transport) method; the parallel transport around a closed path on the unit sphere twists by an angle that is equal to the area enclosed by the path. This is simpler and more accurate and robust than triangulation using Girard, l'Huilier, or Eriksson on each triangle. In particular, since it doesn't triangulate, it suffers no instability except in the unavoidable case when an *edge* (not a diagonal) of the polygon spans 180 degrees. |
| `interpolate` | `interpolate(from, to, fraction)` **Parameters:** - `from`: `LatLng|LatLngLiteral` - `to`: `LatLng|LatLngLiteral` - `fraction`: `number` **Return Value:** `LatLng` Returns the LatLng which lies the given fraction of the way between the origin LatLng and the destination LatLng. |

## [poly](https://developers.google.com/maps/documentation/javascript/reference/3.63/geometry.md.txt#poly)
class


`google.maps.geometry.poly`
class

Utility functions for computations involving polygons and polylines.

Access by calling `const {poly} = await google.maps.importLibrary("geometry")`.   
See [Libraries in the Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/libraries.md.txt).

| ### Static Methods ||
|---|---|
| `containsLocation` | `containsLocation(point, polygon)` **Parameters:** - `point`: `LatLng|LatLngLiteral` - `polygon`: `Polygon` **Return Value:** `boolean` Computes whether the given point lies inside the specified polygon. |
| `isLocationOnEdge` | `isLocationOnEdge(point, poly[, tolerance])` **Parameters:** - `point`: `LatLng|LatLngLiteral` - `poly`: `Polygon|Polyline` - `tolerance`: `number optional` **Return Value:** `boolean` Computes whether the given point lies on or near to a polyline, or the edge of a polygon, within a specified tolerance. Returns `true` when the difference between the latitude and longitude of the supplied point, and the closest point on the edge, is less than the tolerance. The tolerance defaults to 10^-9^ degrees. |