You can not access the hardware settings of a device through the browser. The best you can do is to use HTML5 Geolocation , by accepting the user, to get the location coordinates of the user.
As can be seen in the mozilla documentation , geolocation does not is based, in isolation, on IP. If the device has a GPS, it will use GPS to calculate the location, which can lead to a longer delay to get the data.
Below is an example of how to use Geolocation, taken from the w3School.
<html><head></head><body contenteditable="false">
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
function showError(error) {
switch(error.code) {
case error.PERMISSION_DENIED:
x.innerHTML = "User denied the request for Geolocation."
break;
case error.POSITION_UNAVAILABLE:
x.innerHTML = "Location information is unavailable."
break;
case error.TIMEOUT:
x.innerHTML = "The request to get user location timed out."
break;
case error.UNKNOWN_ERROR:
x.innerHTML = "An unknown error occurred."
break;
}
}
</script>
</body></html>
Now, if you really want to use the device's GPS, you'll need to develop an application and request the user's permission first. This permission is set in APP.
To see the operation go to the sample site, because there are secure connection locks (HTTPS).