安卓系统,在云打包后,不能调取定位的api;
代码如下:
getLocation() {
let _this = this;
if (_this.Locationoff) {
_this.long = 113.5546875000;
_this.lat = 34.6874279493;
_this.scale = 5;
_this.Locationoff = false;
_this.myPlace ='我的位置';
} else {
// //#ifdef APP-PLUS
// plus.geolocation.getCurrentPosition(function(position) {
// _this.long = position.coords.longitude;
// _this.lat = position.coords.latitude;
// _this.scale = 12;
// _this.Locationoff = true;
// _this.myPlace ='全局位置';
// }, function(e) {
// plus.nativeUI.alert("获取定位位置信息失败:请打开您手机的定位功能;" );
// }, {
// geocode: true
// });
// //#endif
uni.getLocation({
type: 'gcj02',
success: function (res) {
_this.long = res.longitude;
_this.lat = res.latitude;
_this.scale = 14;
_this.Locationoff = true;
_this.myPlace ='全局位置';
}
});
}
},
我运用了这两种方法,打包后都无法实现定位功能;

k***@126.com
- 发布:2019-04-26 09:16
- 更新:2019-04-26 12:30
- 阅读:1036

k***@126.com (作者) - 专写bug的宝宝
补充:我的编译器是1.9.3的
getLocation() {
let _this = this;
if (_this.Locationoff) {
_this.long = 113.5546875000;
_this.lat = 34.6874279493;
_this.scale = 5;
_this.Locationoff = false;
_this.myPlace ='我的位置';
} else {
// //#ifdef APP-PLUS
// plus.geolocation.getCurrentPosition(function(position) {
// _this.long = position.coords.longitude;
// _this.lat = position.coords.latitude;
// _this.scale = 12;
// _this.Locationoff = true;
// _this.myPlace ='全局位置';
// }, function(e) {
// plus.nativeUI.alert("获取定位位置信息失败:请打开您手机的定位功能;" );
// }, {
// geocode: true
// });
// //#endif
uni.getLocation({
type: 'gcj02',
success: function (res) {
_this.long = res.longitude;
_this.lat = res.latitude;
_this.scale = 14;
_this.Locationoff = true;
_this.myPlace ='全局位置';
}
});
}
},
DCloud_Android_ST
真机调试定位没有问题?云打包后定位无法正常运行,这种情况可能是定位相关第三方SDK 的KEY配置有错误
2019-04-26 12:33