wx.onLocationChange获取不到speed数据,问题出在哪里?
遇到的问题:开发一个上报地理位置的小程序,打包成体验版在ios下测试;调用startLocationUpdateBackground接口后,在onLocationChange中可以正常获得数据,除了speed一直返回-1。有哪位大神知道问题在哪里吗? [代码] [代码] var that=this; [代码] [代码] [代码]wx.startLocationUpdateBackground({[代码] [代码] [代码][代码]success: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]console.info([代码][代码]"持续定位初始化成功"[代码][代码]);[代码][代码] [代码][代码]wx.onLocationChange([代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.info([代码][代码]'['[代码] [代码]+ util.formatTime([代码][代码]new[代码] [代码]Date()) + [代码][代码]']位置改变:'[代码][代码], res);[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]currentLongitude: res.longitude,[代码][代码] [代码][代码]currentLatitude: res.latitude,[代码][代码] [代码][代码]speed: res.speed,[代码][代码] [代码][代码]altitude: res.altitude[代码][代码] [代码][代码]});[代码][代码] [代码][代码]that.doReport(); [代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]console.info([代码][代码]"持续定位初始化失败"[代码][代码]);[代码][代码] [代码][代码]wx.getSetting({[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]if[代码] [代码](res.authSetting[[代码][代码]"scope.userLocationBackground"[代码][代码]] != [代码][代码]true[代码] [代码]){[代码][代码] [代码][代码]wx.showModal({[代码][代码] [代码][代码]title: [代码][代码]'提示'[代码][代码],[代码][代码] [代码][代码]content: [代码][代码]'您需要允许(使用小程序期间和离开小程序后)选项'[代码][代码],[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]if[代码] [代码](res.confirm) { [代码][代码]//这里是点击了确定以后[代码][代码] [代码][代码]wx.openSetting({[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]that.doMain();[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]console.info([代码][代码]"打开设置失败"[代码][代码])[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{ [代码][代码]//这里是点击了取消以后[代码][代码] [代码][代码]//console.log('用户点击取消')[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{ console.info([代码][代码]"未知错误"[代码][代码]); }[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}) [代码][代码] [代码][代码]}[代码][代码]})[代码]