sonalid1701
posted this
22 July 2022

Hi,
Hope everyone's doing well.
Was referring to some interview articles.
Here the code requests users' permission for accessing their coordinates via geolocation API. How many other methods there exist in Geolocation Object and what would their usage be in real-time.
<!DOCTYPE html>
<html>
<body>
<p>Click "try it" 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 functionality is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
TIA..!
Hi, Hope everyone's doing well. Was referring to some interview articles. Here the code requests users' permission for accessing their coordinates via geolocation API. How many other methods there exist in Geolocation Object and what would their usage be in real-time. <!DOCTYPE html> <html> <body> <p>Click "try it" 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 functionality is not supported by this browser."; } } function showPosition(position) { x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; } </script> </body> </html> [Source][1] TIA..! [1]: https://www.interviewbit.com/html-interview-questions/Last edited 22 July 2022 by sonalid1701
Vote to pay developers attention to this features or issue.