其他分享
首页 > 其他分享> > 获取当前设备位置(shuntian)

获取当前设备位置(shuntian)

作者:互联网

getUserLocation:function(){
//获取当前设备位置
plus.geolocation.getCurrentPosition(function(position) {
// console.log(JSON.stringify(position))
if(position.coords.longitude == "5e-324" || position.coords.latitude == "5e-324"){
plus.storage.setItem('userPoint',JSON.stringify(null))
return
}
var userPoint = new plus.maps.Point(position.coords.longitude, position.coords.latitude);
var storagePoint = plus.storage.getItem('userPoint')
plus.storage.setItem('userPoint', JSON.stringify(userPoint));
plus.storage.setItem('userPointInfo', position.addresses); //导航红包用到的数据
}, function(error) {
if(app.time > 0){
app.getUserLocation()
app.time--
}else{
}
}, {
provider: 'baidu',
enableHighAccuracy: true,
coordsType: 'bd09ll'
})
},

标签:userPoint,shuntian,app,coords,storage,获取,plus,position,设备
来源: https://www.cnblogs.com/yhxy/p/16268891.html