Skip to content

Commit

Permalink
Create geo.js
Browse files Browse the repository at this point in the history
  • Loading branch information
rickcomics authored Oct 26, 2024
1 parent 2f7afd3 commit 7ad6d6b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions geo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const myElement = document.getElementById("demo");

function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
myElement.innerHTML = "Geolocation is not supported by this browser.";
}
}

function showPosition(position) {
myElement.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}

0 comments on commit 7ad6d6b

Please sign in to comment.