Tell us what’s happening:
Hello everyone!
When I submit my code, it always returns this message: “You should display the user’s position within the data
element.”
Well, I’m seeing the user’s position in the screen and I used the getElementById('data')
to access the data
element.
So what am I doing wrong?
PS.: In this GitHub issue, people already had the same problem in the past
Your code so far
<script>
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
document
.getElementById("data")
.innerHTML =
"latitude: " + position.coords.latitude +
"<br>longitude: " + position.coords.longitude
})
}
</script>
<h4>You are here:</h4>
<div id="data">
</div>
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
.
Challenge: Get Geolocation Data to Find A User’s GPS Coordinates
Link to the challenge:
https://www.freecodecamp.org/learn/data-visualization/json-apis-and-ajax/get-geolocation-data-to-find-a-users-gps-coordinates