Code Monkey home page Code Monkey logo

wechat-coordinate's Introduction

wechat-Coordinate

微信小程序经纬度转换,坐标系转换💯 WGS-84(国际标准)、GCJ-02(火星坐标) 、百度坐标相互转换

此转换库为本地坐标转换库,不需要依赖网络资源,计算速度高。可在极短时间内转换大量坐标。
如果使用过程中有问题,请issue我 (。♥‿♥。)
如果觉得对你还有些用,顺手点一下star吧 (。♥‿♥。)

Demo截图

在这里插入图片描述

方法

提供以下方法

/**
 *  判断经纬度是否超出**境内
 */
function isLocationOutOfChina(latitude, longitude) 

/**
 *  将WGS-84(国际标准)转为GCJ-02(火星坐标):
 */
function transformFromWGSToGCJ(latitude, longitude)

/**
 *  将GCJ-02(火星坐标)转为百度坐标:
 */
function transformFromGCJToBaidu(latitude, longitude) 

/**
 *  将百度坐标转为GCJ-02(火星坐标):
 */
function transformFromBaiduToGCJ(latitude, longitude) 

/**
 *  将GCJ-02(火星坐标)转为WGS-84:
 */
function transformFromGCJToWGS(latitude, longitude) 

如何使用

下载此项目,将项目中的WSCoordinate.js复制到您的项目根目录utils文件夹(或其他文件夹)。

在您要使用的页面对应的.JS文件中引入

    var util = require('../../utils/WSCoordinate.js')  

在您需要转换的地方使用

    //将WGS-84(国际标准)转为GCJ-02(火星坐标)
    var result1 = util.transformFromWGSToGCJ(32.0806670849, 118.9060163095);
    
    // 将GCJ-02(火星坐标)转为百度坐标
    var result2 = util.transformFromGCJToBaidu(32.0806670849, 118.9060163095);

    //将百度坐标转为GCJ-02(火星坐标)
    var result3 = util.transformFromBaiduToGCJ(32.0806670849, 118.9060163095);

    //将GCJ-02(火星坐标)转为WGS-84
    var result4 = util.transformFromGCJToWGS(32.0806670849, 118.9060163095);

方法的返回值result是一个对象,格式为

{
	latitude: 纬度的值, 
	longitude: 经度的值
}

如果使用过程中有问题,请issue我 (。♥‿♥。)
如果觉得对你还有些用,顺手点一下star吧 (。♥‿♥。) 你的支持是我继续的动力。

wechat-coordinate's People

Contributors

zws-china 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.