Javascript jQuery mobile和html5位置权限和值
我正在尝试制作一个android webview应用程序来使用用户地理位置:Javascript jQuery mobile和html5位置权限和值,javascript,html,jquery-mobile,geolocation,user-permissions,Javascript,Html,Jquery Mobile,Geolocation,User Permissions,我正在尝试制作一个android webview应用程序来使用用户地理位置: if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition,showError,{maximumAge:60000, timeout:20000, enableHighAccuracy:true}); console.log("Location supported")
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition,showError,{maximumAge:60000, timeout:20000, enableHighAccuracy:true});
console.log("Location supported")
}
要显示成功的立场,请执行以下操作:
function showPosition(position) {
currentLatitude = position.coords.latitude;
currentLongitude = position.coords.longitude;
console.log( "In show : " + position.coords.latitude + ", " +position.coords.longitude)
}
要显示错误代码,请执行以下操作:
function showError(error) {
var x = $('#curr_loc_target');
console.log("In show Error");
switch(error.code) {
case error.PERMISSION_DENIED:
console.log("permission denied");
break;
case error.POSITION_UNAVAILABLE:
console.log("Location information is unavailable.");
break;
case error.TIMEOUT:
console.log("The request to get user location timed out.");
break;
case error.UNKNOWN_ERROR:
console.log("An unknown error occurred.");
break;
}
它在任何桌面web浏览器上都可以正常工作,但在移动浏览器上则不行,存在以下问题:
1-应用程序没有向用户请求使用位置的权限,而淋浴ROR函数的错误是超时,我认为webview代码与此无关,因为
即使在移动浏览器上,问题也是一样的
2-经度、纬度的值等于“”。
如果有人认为我需要在这里添加它,我会的
谢谢你的帮助