|
为什么地理位置插件第一次定位可以成功,后面都失败了
/*获取地址*/
getThePosition();
function getThePosition(){
var uName = justep.Shell.userName.get();
var uId = justep.Shell.userId.get();
if(justep.Shell.userId.get() == '' || justep.Shell.userId.get() == undefined){
}else{
navigator.geolocation.getCurrentPosition(onSuccess, onError, null)
function onSuccess(data){
var x = data.coords.longitude;
var y = data.coords.latitude;
$.ajax({
type: "POST",
url: 'http://192.168.40.250:8099/Task/findAppXJ',
dataType: 'json',
data: {
"x": x,
"y": y,
"userId": uId,
"userName": uName,
},
success: function(obj){
console.log(obj)
console.log(x + '|' + y + '|' + uId + '|' + uName)
},
});
}
function onError(msg){
console.log("定位失败!");
}
}
}
/*每个一分钟获取一次*/
window.setInterval(function(){
getThePosition();
},10 * 1000) |
|