嘿伙计们,所以我正在使用navigator.geolcation这样:
navigator.geolocation.getCurrentPosition(
displayBestPosition,
displayError,
{ enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
);
我在我的Android设备浏览器上访问它,所以它使用我的gps。然而,当我在里面并且我不断超时时,我想从gps切换到从wifi获取位置。有没有办法做到这一点?
答案 0 :(得分:1)
<head>
<script>
var myip;
function callback(data) {
alert(data.city);
}
function request_location() {
var oHead = document.getElementsByTagName('head')[0];
var oScript = document.createElement("script");
oScript.type = "text/javascript";
oScript.src = "http://ip-api.com/json/" + myip + "?callback=callback";
oHead.appendChild(oScript);
}
</script>
<script type="text/javascript" src="http://l2.io/ip.js?var=myip" onload="request_location();"></script>
</head>