michliu
michliu
  • 发布:2015-09-17 10:14
  • 更新:2016-03-03 21:23
  • 阅读:1914

定位偏移問題.

分类:HTML5+

plus.geolocation.getCurrentPosition( geoInf, function ( e ) {
console.log( "获取百度定位位置信息失败:"+e.message );
},{provider:'baidu'});

得到的經緯度座標都會偏移...該如何解決呢?

2015-09-17 10:14 负责人:无 分享
已邀请:
njjbuaa

njjbuaa

用百度获取的坐标和经纬度坐标是会有偏移的,百度的是用百度经纬度坐标系,GPS的是用WGS-84坐标系。
我用的百度和GPS坐标互换的方法
GPS换百度坐标:
plus.maps.Map.convertCoordinates(gpsPoint,{coordType: "wgs84"},function(event){
var baiduPoint = event.coord; // 转换后的百度坐标值
},function(e){
console.log("Failed:"+JSON.stringify(e));
});

百度坐标换GPS坐标:
var sourePoint = baiduPoint; //百度坐标
plus.maps.Map.convertCoordinates(baiduPoint,{coordType: "wgs84"},function(event){
var tmpPoint = event.coord;
var x = 2 * sourePoint.longitude - tmpPoint .longitude;
var y = 2 * sourePoint.latitude - tmpPoint .latitude;
var gpsPoint = new plus.maps.Point(x, y); // 转换后的GPS坐标值
},function(e){
console.log("Failed:"+JSON.stringify(e));
});
参考网站:http://hunray.iteye.com/blog/1404129

  • 云钦

    请问,如何才能获取到GPS坐标呢


    2016-04-20 18:37

  • njjbuaa

    plus.geolocation.getCurrentPosition(function(p) {

    }, function(e) {

    }); 取GPS坐标


    2016-06-02 17:32

  • njjbuaa

    plus.geolocation.getCurrentPosition( function ( p ) {

    }, function ( e ) {

    } , {

    provider: 'baidu',

    });取百度坐标


    2016-06-02 17:33

云钦

云钦 - 学习中

留个爪印,明天细看

该问题目前已经被锁定, 无法添加新回复