I am using navigator.geolcation like this:
navigator.geolocation.getCurrentPosition(
displayBestPosition,
displayError,
{ enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
);
I'm accessing it on my android device browser so its using my gps. However, when I am inside and I keep getting timeouts I'd like to switch from gps to getting the location from wifi. Is there any way to do this?
DEMO FIDDLE
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With