# sameplace-js

> a simple gps coordinate transformer.

Latest version **0.0.3** (published 2017-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install sameplace-js
pnpm add sameplace-js
yarn add sameplace-js
bun add sameplace-js
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2017-06-24 |
| First published | 2017-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | DreamAndDead |
| Maintainers | dreamanddead |
| Keywords | gps |

## Links

- npm: https://www.npmjs.com/package/sameplace-js
- Repository: https://github.com/DreamAndDead/sameplace-js
- Homepage: https://github.com/DreamAndDead/sameplace-js#readme
- Issues: https://github.com/DreamAndDead/sameplace-js/issues
- npm.io page: https://npm.io/package/sameplace-js

## Dependencies (1)

- [invariant](https://npm.io/package/invariant.md) ^2.2.2

## Recent versions

- 0.0.3 (latest) — 2017-06-24
- 0.0.2 — 2017-06-24
- 0.0.1 — 2017-06-24

## README

# sameplace-js
GPS坐标系统有多种标准，遵循不同的标准，相同的GPS经纬度坐标对应不同的绝对地址（地球上实际的一点）。sameplace-js在不同的标准间转换GPS坐标值。

## intro 介绍

谷歌地球、腾讯地图、高德地图、百度地图针对不同的大地地理坐标系标准制作经纬度，由于参照物不一样，得出的经纬度值不同。

+ WGS84坐标系：地球坐标系，国际上通用的坐标系
+ GCJ02坐标系：火星坐标系，WGS84坐标系经加密后的坐标系
+ BD09坐标系：百度坐标系，GCJ02坐标系经加密后的坐标系

硬件/谷歌地球卫星采用WGS84地理坐标系（中国范围除外），腾讯地图/高德地图采用GCJ02地理坐标系，百度地图采用BD09坐标系。

## install 安装

    npm install --save sameplace-js

## example 示例

```javascript
// ES6
import transformer, { makeCoord, coordLat } from 'sameplace-js'

let wgs = makeCoord(22.34, 44.233511);
let bd = transformer('wgs', 'bd', wgs);

console.log('bd latitude', coordLat(bd));
```

## usage 用法
```javascript
// ES6
import transformer, { makeCoord, coordLat, coordLon } from 'sameplace-js'

// CommonJS
var sameplace = require("sameplace-js");
var transformer = sameplace.default;
var makeCoord = sameplace.makeCoord;
var coordLat = sameplace.coordLat;
var coordLon = sameplace.coordLon;

// AMD
define([ "sameplace-js", function(sameplace) {
    // sameplace is available
    var sameplace = require("sameplace-js");
    var transformer = sameplace.default;
    var makeCoord = sameplace.makeCoord;
    var coordLat = sameplace.coordLat;
    var coordLon = sameplace.coordLon;
});
```

## API
type:
- number: latitude, longitude
- object: coord
- string (only 'wgs', 'gcj' or 'bd'): from, to

```
// create a coord
makeCoord(latitude, longitude) ==> coord

// get latitude
coordLat(coord) ==> latitude

// get longitude
coordLon(coord) ==> longitude

// coordinate transformer
transformer(from, to, fromCoord) ==> toCoord
```

## ref 参考链接

[gps坐标标准的区别](http://www.jianshu.com/p/0fe30fcd4ae7)

[gps坐标查询（支持多标准）](http://www.gpsspg.com/maps.htm)

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