mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-07-30 19:35:55 +02:00
57 lines
1.3 KiB
Markdown
57 lines
1.3 KiB
Markdown
# @digitransit-search-util/digitransit-search-util-distance
|
|
|
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
|
|
## distance
|
|
|
|
Calculates distance betweeh two points.
|
|
|
|
### Parameters
|
|
|
|
- `latlon1` **[Object][1]**
|
|
- `latlon2` **[Object][1]**
|
|
|
|
### Examples
|
|
|
|
```javascript
|
|
const latlon1 = {
|
|
lat: 3,
|
|
lon: 2,
|
|
};
|
|
const latlon2 = {
|
|
lat: 4,
|
|
lon: 1,
|
|
};
|
|
digitransit-util.distance(latlon1, latlon2);
|
|
//=157105.77709637067
|
|
```
|
|
|
|
Returns **[Number][2]** distance between two points
|
|
|
|
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
|
|
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
|
|
<!-- This file is automatically generated. Please don't edit it directly:
|
|
if you find an error, edit the source file (likely index.js), and re-run
|
|
./scripts/generate-readmes in the digitransit-util project. -->
|
|
|
|
---
|
|
|
|
This module is part of the Digitransit-ui project. It is maintained in the
|
|
[HSLdevcom/digitransit-ui](https://github.com/HSLdevcom/digitransit-ui) repository, where you can create
|
|
PRs and issues.
|
|
|
|
### Installation
|
|
|
|
Install this module individually:
|
|
|
|
```sh
|
|
$ npm install @digitransit-search-util/digitransit-search-util-distance
|
|
```
|
|
|
|
Or install the Digitransit-util module that includes it as a function:
|
|
|
|
```sh
|
|
$ npm install @digitransit-util/digitransit-util
|
|
```
|