Weather app : page loads before location

Weather app : page loads before location
0.0 0

#1

My pen : https://codepen.io/mvishnoi/full/vjoMoX/

Hi,
Rather than using FCC api i am using google location api to get location. but it takes some time and i have to put a button there to load rest of weather data after it completes getting location. I want something like loading feature. Once i allow page to access my location, page should wait to get every possible data and only then loads.

How is that possible ?

P.S : as always any other suggestions are also welcome.


#2

Just move all the code you have in the callback function of your button’s click event handler into the showPosition function (after the two lines were you assign a1 and b1 values).

Also, you will need to fix a slight issue with the google api. Change the http to https.


#3

Thanks. It worked. I corrected google api as well. :slight_smile: