Socket
Socket
Sign inDemoInstall

coordinate-transfer

Package Overview
Dependencies
31
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    coordinate-transfer

坐标转换库,支持百度/高德/腾讯坐标互转。


Version published
Weekly downloads
8
Maintainers
1
Install size
3.70 MB
Created
Weekly downloads
 

Readme

Source

Coordinate-Transfer

坐标转换库,支持百度/高德/腾讯坐标互转。

Install

$yarn add coordinate-transfer

Usage

使用示例:

import {
  transTMapToBMap,
  transBMapToTMap,
  transCoordinate
} from 'coordinate-transfer'

// 使用方法1: 直接调用转换方法
transTMapToBMap(120.8484, 30.2121)
transBMapToTMap(120.8484, 30.2121)

// 使用方法2: 调用父级方法, 通过此方法传入不同的参数可以调用上面的两个转换方法
transCoordinate({
  from: 'tmap',
  to: 'bmap',
  lng: 120.8484,
  lat: 30.2121
})

API

直接调用转换方法或调用 transCoordinate 方法均可达到转换坐标系的目的, 区别在于方法传入的参数值和类型不同,开发者可以按照自己的喜好来选用。

直接调用转换方法

直接调用 transTMapToBMap, transBMapToTMap 方法可参考如下参数列表。

参数默认值必填说明类型/可选值
lng经度number
lat纬度number

调用 transCoordinate 方法

调用 transCoordinate 方法可参考如下参数列表。

transCoordinate 方法的参数是一个对象, 是为了以后版本的功能扩展性而定义的。参数对象的属性参考如下:

属性默认值必填说明类型/可选值
lng经度number / 合法的经度值
lat纬度number / 合法的纬度值
from传入坐标类型string / bmap-百度地图 tmap-腾讯地图 gmap-高德地图
to目标坐标类型string / bmap-百度地图 tmap-腾讯地图 gmap-高德地图

Remark

腾讯和高德的经纬度是同一坐标系下的,可以通用,而百度与两者稍有不同,需要相互转换。

FAQs

Last updated on 01 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc