继承人JavaScript我用于我的网站,它适用于我可以在办公室找到的每个浏览器。
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
//call your function that responds to lat & long
}, // next function is the error callback
function (error) {
switch (error.code) {
case error.TIMEOUT:
alert("Timeout");
break;
case error.POSITION_UNAVAILABLE:
alert("Position unavailable");
break;
case error.PERMISSION_DENIED:
alert("Permission denied");
break;
case error.UNKNOWN_ERROR:
alert("Unknown error");
break;
}
}
);
}
通过该代码中的错误检查,您应该能够从那里诊断错误。
检查[本] [1]页面及其解答为您的答案。 [1]:http://stackoverflow.com/questions/11280946/unable-to-get-gps-coordinates-using-javascript-on-browser-in-android/11298468#11298468 – axs