# LATLNGDISTANCE

**The function LATLNGDISTANCE returns the distance between two global positions in miles, kilometers, or nautical miles.**

#### Declaration

```javascript
LATLNGDISTANCE(latitude1, longitude1, latitude2, longitude2, unit_string) -> distance
```

#### Parameters

**latitude1** (type: `Number`) The latitude of the first position.

**longitude1** (type: `Number`) The longitude of the first position.

**latitude2** (type: `Number`) The latitude of the second position.

**longitude2** (type: `Number`) The longitude of the second position.

**unit\_string** (type: `string`, _default: **"m"** - miles_) The unit of measurement the result should represent. Valid units are:

* "k" - kilometers
* "m" - miles
* "n" - nautical miles

#### Return Values

**distance** (type: `Number`) The distance between the two positions in the units specified by the **unit\_string**.

#### Examples

The distance between the latitude/longitude position (40.7648, -73.9797) and (37.431136, -122.14044) is 2560.1436555900605 miles.

```javascript
LATLNGDISTANCE(40.7648, -73.9797, 37.431136, -122.14044) -> 2560.1436555900605
```

The same distance in kilometers is 4120.151831261931

```javascript
LATLNGDISTANCE(40.7648, -73.9797, 37.431136, -122.14044, "k") -> 4120.151831261931
```
