DedicatedNoobGuy DedicatedNoobGuy - 1 month ago 16
HTML Question

Geolocation not working for me

Good Day,

I was having a bit of a problem getting my project to display the local weather together. I think once I have the coordinates set then it should be smooth sailing, but for some reason I've been unable to get the longitude and latitude to show. I had previously had an issue with not having the proper javascripts loaded so I made sure that I loaded up geolocation and jquery for this one. I also made sure my chrome was up to date, but it worked with the freecodecamp that I programmed so don't think that's the problem.

In fact I loaded the script I had written for freecodecamp almost verbatim to try to get this right before I customized the code, but like I said, it's not loading in my pen, so any help would be more than appreciated. Thanks!

HTML

<h1>
Your Local Weather Forecast
</h1>
<h2>
At your location of:
</h2>
<script>


if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position)
{$("#data").html("latitude: " + position.coords.latitude + "<br>longitude" + position.coords.longitude);

});
}


</script>
<div id = "data">
<h4>You are here:</h4>

</div>

Answer

If you are trying to do this in chrome and in http, it will not work, because chrome does not allow it anymore, either use a different browser or use https :)

Comments