首页 > 微信定位坐标用于百度地图定位换算的问题,求助!

微信定位坐标用于百度地图定位换算的问题,求助!

114.057868,22.543099
这是微信api给出坐标点,用到百度地图时,会有很大的距离差距,请问是坐标换算问题吗?哪位大神知道具体的转换方法


如果可以拿到html5geolocation,可以用那个。

    if (navigator.geolocation){
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        $("#lable").html("Geolocation is not supported by this browser.");
    }
    //曾经用google地图写的 不知道有没有参考价值
    function showPosition(position) {
        var geoLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
        
        var mapOptions = {
            zoom: 15,
            center: geoLocation
        }
        var map = new google.maps.Map(document.getElementById('map'), mapOptions);
        for (var i = 0; i < restaurants.length; i++) {
          addMarker(position.coords.latitude,position.coords.longitude);
        }
        function addMarker(position,title) {
            var markers = [];
            markers.push(new google.maps.Marker({
                position: position,
                map: map,
                animation: google.maps.Animation.DROP,
                title:title
            })
            )
        }
    }

给你一个GCJ02 转 BD09的算法

$.bd_encrypt = function(gg_lat, gg_lon){
    var x_pi = 3.14159265358979324 * 3000.0 / 180.0;
    var x = gg_lon, 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_lon = z * Math.cos(theta) + 0.0065;  
    var bd_lat = z * Math.sin(theta) + 0.006;  

    var bd_obj = new Object();
    bd_obj.lon = bd_lon;
    bd_obj.lat = bd_lat;

    return bd_obj;
};

问题还是在差异,2个地图的算法不一定统一, 仔细看微信的文档。

type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'

再看百度地图的api文档,写的很清楚了。

http://lbsyun.baidu.com/index...

所以就是说,这两根本不是同一个东西。。


个人认为这个是因为获取的坐标点本身的问题!
可以使用HTML5自带的那个获取当前坐标,你会发现准多了!


这是百度地图与腾讯地图的差异,你用腾讯地图的接口去转换坐标的位置就准了。

【热门文章】
【热门文章】