我不是风
我不是风
  • 发布:2016-06-16 16:55
  • 更新:2016-06-17 15:25
  • 阅读:1079

HTML5+ Geolocation模块管理设备位置信息

分类:HTML5+

plus.geolocation.getCurrentPosition提示无法获取有效的位置信息,android版本5.1,内核版本3.10.65;当使用android版本4.4.4,内核版本3.10.28正常,为什么啊?和手机的版本有关系吗?请求官方人员的帮助

2016-06-16 16:55 负责人:无 分享
已邀请:
BoredApe

BoredApe - 有问题就会有答案。

真机调试还是在线打包之后? 代码是怎么写的

  • 我不是风 (作者)

    打包之后会这样,真机调试正常;代码是下面的```javascript

    plus.geolocation.getCurrentPosition(function (p) {

    gpsx = p.coords.longitude;

    gpsy = p.coords.latitude;

    //var coords = cts.wgs84ToTj90([p.coords.longitude,p.coords.latitude]);

    var coords = webgis.wgs84ToTj90([p.coords.longitude,p.coords.latitude]);

    x = coords[0];

    y = coords[1];

    webgis.setCurrentLocation(p.coords.longitude,p.coords.latitude);

    //webgis.setCurrentLocation(117.14819613690125,39.231554362887984);

    webgis.showCurrentLocation(); //在地图上定位这个位置

    getNearData();

    }, function ( e ) {

    // console.log("Gelocation Error: code - "+e.code+"; message - "+e.message);

    switch(e.code) {

    case e.PERMISSION_DENIED:

    plus.nativeUI.toast('系统不允许程序获取定位功能');

    break;

    case e.POSITION_UNAVAILABLE:

    plus.nativeUI.toast('无法获取有效的位置信息');

    break;

    case e.TIMEOUT:

    plus.nativeUI.toast('获取位置信息超时');

    break;

    case e.UNKNOWN_ERROR:

    plus.nativeUI.toast('其它未知错误导致无法获取位置信息');

    break;

    default:

    plus.nativeUI.toast(e.message);

    }

    }, {

    enableHighAccuracy: false,

    timeout: 20000,

    maximumAge: 0,

    provider: 'system',

    geocode: false

    })



    总是返回error方法中的e.POSITION_UNAVAILABLE参数,不知道什么原因

    2016-06-17 15:27

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