# compatible-coordinates

> Work with map coordinates across libraries without the tears

Latest version **1.0.3** (published 2017-12-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install compatible-coordinates
pnpm add compatible-coordinates
yarn add compatible-coordinates
bun add compatible-coordinates
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-12-20 |
| First published | 2017-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Albin Ekblom |
| Maintainers | albinekb |

## Links

- npm: https://www.npmjs.com/package/compatible-coordinates
- Repository: https://github.com/albinekb/compatible-coordinates
- Homepage: https://github.com/albinekb/compatible-coordinates#readme
- Issues: https://github.com/albinekb/compatible-coordinates/issues
- npm.io page: https://npm.io/package/compatible-coordinates

## Recent versions

- 1.0.3 (latest) — 2017-12-20
- 1.0.2 — 2017-12-20
- 1.0.1 — 2017-12-20

## README

# Compatible coordinates

If you ever worked with coordinates on the web you probably know that there's no "standard" way of passing them around to libraries etc.

**Examples that this solves:**

* Google maps wants `{ lat, lng }` and `[latitude, longitude]`
* SMHI (Swedish weather) wants `{ lat, lon }`
* [cheap-ruler](https://github.com/mapbox/cheap-ruler#distancea-b) wants `[longitude, latitude]` (reversed!!!!)

Or versose, because tab completion and readability `{ latitude, longitude }`

## Install

```sh
yarn add compatible-coordinates
```

```sh
npm install --save compatible-coordinates
```

## Usage

```js
const CompatibleCoordinates = require('compatible-coordinates')

const home = new CompatibleCoordinates(59, 18)

console.log(home.latitude) //=> 59
console.log(home.lat) //=> 59
console.log(home[0]) //=> 59

console.log(home.longitude) //=> 18
console.log(home.lng) //=> 18
console.log(home.lon) //=> 18
console.log(home[1]) //=> 18

console.log(home) //=> [59, 18]
```

### Reversed tuple

For some reason, [cheap-ruler](https://github.com/mapbox/cheap-ruler#distancea-b) expects the coordinates in [longitude, latitude], to reverse the tuple without changing the behaviour of the other properties, you can use **.reversed()**

```js
const homeReversed = home.reversed()

console.log(home[0]) //=> 59
console.log(homeReversed[0]) //=> 18

console.log(homeReversed.longitude) // => 18
```

## Credits

[@linusu](https://github.com/linusu) for coming up with this clever but simple solution ⚡️

---
_Source: https://npm.io/package/compatible-coordinates · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
