Geolocatiation is not working

This is my project code

I’ve tried so many ways to see the latitude, but it’s not working, I’ve seen other pen code and It’s working (

I copied the code in the geolocatitation challenge and it isn’t still working.

I don’t know what to do.

I don’t know the exact explanation - but it’s a scope issue that probably has to do with how js is writing - i rewrite your code like this

 navigator.geolocation.getCurrentPosition(function(position) {
    var latitude = position.coords.latitude;
     var longitude = position.coords.longitude;

and it did work properly - i also reset it to what you had previously

Scope is tricky business - it might be a document.ready issue

I’ve been banging my head on the wall for this for a day now… having the exact same issues as you. Code from other geolocation examples seems to work but when I run it in my own pen it gets error code 1. I’m using chrome, not sure if that’s an issue.

Now, I’m using this to get the locatitation"

Yep I just found that and was coming back to post here. Thanks and good luck!

Your current code has a typo due to the case sensitive nature of javascript.

Instead of $.getJson, use $.getJSON. That should help you make the request.

Thans all, my code is now working in my lnotebook, but not in codepen.

@sergiosalfer and @NickWright, as I mentioned here: , the problem is to do with Google depreciating navigator.geolocation if the page is accessed from http, as opposed to https.

The work around is to manually put https:// in front of, and then give that link to others looking at your page. I may also put up an alert message to that effect.

Thanks for the link, though it isn’t as accurate.

I also found this link on the same issue: