Local Weather App - HTML Geolocation not working

Local Weather App - HTML Geolocation not working
0.0 0

#1

Hi everyone, this is my first time posting and I hope it’s okay to ask for help here.

A week ago I had the functionality of my weatherapp working locally only to find out that the APIs I was using do not support HTTPS and code does not support HTTP. So doing it all over again.

Right now, I’m just trying to get HTML geolocation working, so the project is at a really early stage but I just can’t figure out what is wrong with my code.

Here is my codepen
https://codepen.io/yogiwhocodes/pen/YYBJGR


#2

The code that calls the geolocation code is in a function that is not called anywhere. Add geoFindMe(); at the bottom of your code.

Then there’s an error with setting #location's HTML. $('#location').html is a function, so you need to call it (and pass it the string).


#3

Thanks a lot for your quick reply! :slight_smile:

That I call the function in HTML button onclick tag is not enough?
Where in the code do I have to enter geoFindMe() exactly?

And where do I need to call the location.html function?

Sorry for all the questions, but I feel I’m missing some important knowledge about structuring my JS and I really wanna learn it. :smiley:


#4

Right after the very last closing brace will work.

You’ve already actually done it inside the error function. Just do the same in the success function.

Another tip: You can click the dropdown button at the upper right of the JS editor, then hit Tidy JS to arrange your code.


#5

thanks so much for your help! :slight_smile: