Coder Social home page Coder Social logo

map-selector's Introduction

百度地图描点工具

技术栈

  • jQuery
  • Material based on Bootstrap v4
  • ACE Editor
  • 百度地图 JavaScript API
  • 百度地图 鼠标绘制工具库

Usage

git clone https://github.com/leslieeilsel/BaiduMapTool.git

# 在浏览器中打开index.html即可

TODO

  • BUG修复
  • 转化为高德地图坐标
  • 转化为GPS坐标
  • UI优化
  • 代码优化
  • Vue版本
  • React版本

坐标转化

  • 百度官方API

    http://lbsyun.baidu.com/index.php?title=webapi/guide/changeposition
  • 高德官方API

    https://lbs.amap.com/api/webservice/guide/api/convert/
  • 自定义算法

    百度、高德提供的坐标转换是HTTP接口,单次响应时间在100ms左右。

    如果请求次数不多,这样的延迟可以忽略。

    但是在大批量转化时,就会出现较长的延迟,这时就需要使用本地算法。

    // 百度坐标转高德(传入经度、纬度)
    function bd_decrypt(bd_lng, bd_lat) {
        var X_PI = Math.PI * 3000.0 / 180.0;
        var x = bd_lng - 0.0065;
        var y = bd_lat - 0.006;
        var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * X_PI);
        var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * X_PI);
        var gg_lng = z * Math.cos(theta);
        var gg_lat = z * Math.sin(theta);
        return {lng: gg_lng, lat: gg_lat}
    }
    
    // 高德坐标转百度(传入经度、纬度)
    function bd_encrypt(gg_lng, gg_lat) {
        var X_PI = Math.PI * 3000.0 / 180.0;
        var x = gg_lng, y = gg_lat;
        var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * X_PI);
        var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * X_PI);
        var bd_lng = z * Math.cos(theta) + 0.0065;
        var bd_lat = z * Math.sin(theta) + 0.006;
        return {
            bd_lat: bd_lat,
            bd_lng: bd_lng
        };
    }

    以下是php版本的算法

    https://beltxman.com/archives/1628.html

map-selector's People

Contributors

leslieeilsel 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.