Show the local weather app

Show the local weather app
0.0 0

#1

Please help me figure out why my weather app is not changing the my longitude and latitude variables. https://codepen.io/MUNACHI/pen/RMXrzX


#2

Actually the problem seems to be on your watchPosition method, that doesn’t seem to be working.
I used getCurrentPosition for mine. In your code latitude and longitude are given as undefined, that’s why it fails.


#3

I’ve done that but the problem persists


#4

Right, it seems that this needed a bit of tinkering. Apparently the function inside getCurrentPosition is not capable of modifing variables outside of itself (I don’t realy know why).

First declare the variables latitude and longitude with the keyword var inside the getCurrentPosition function and get rid of the global ones.

Second move your getJSON function inside the getCurrentPosition function (forget about the document. ready).

That should make everything live inside the same function scope. it does work for me now and it has the right location.

Give it a try and let me know. If you need I can post the code here.


#5

It worked and i’m immeasurably grateful for your help, thanks a million!