Giter VIP home page Giter VIP logo

coordinate-transfer's Introduction

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

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

coordinate-transfer's People

Contributors

dependabot[bot] avatar lexmin0412 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.