Reputation: 273
I am using the below code to get the lat and long, on the web browser chrome, firefox I am able to get the location but when i am running the site on IOS safari and firefox I am unable to fetch latitude and longitude.
<!DOCTYPE html>
<html>
<body>
<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);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
Upvotes: 0
Views: 1474
Reputation: 71
Turn on the location service for the browser app.
-Tap the Settings application -Tap Privacy -Tap Location Services -Toggle the switch to On
Upvotes: 2