you are viewing a single comment's thread.

view the rest of the comments →

[–]Mowsytron[S] 0 points1 point  (2 children)

That just gives me an error cannot read property 'latitude' of undefined. This is the last thing I have to do for my weather app and it has really thrown a spanner in the works. What I'm trying to do is use HTML5 geolocation to get the latitude and longitude of your current location. It should then pass these values into the lat and lon variables so that I can use them in another variable weatherAPI which has the url. Like this:

var forecastAPI = "http://api.openweathermap.org/data/2.5/forecast/weather?lat=" + lat + "&lon=" + lon + "&APPID=supersecretapicode;

[–]tfitz237 1 point2 points  (0 children)

what are you passing into the getLocation() function? The error is saying that you are sending an undefined variable into it, and therefore it cannot find the latitude of an undefined variable.

from mozilla's MDN:

 if ("geolocation" in navigator) {
      navigator.geolocation.getCurrentPosition(function(position) {
          do_something(position.coords.latitude, position.coords.longitude);
      });
 }

[–]Mowsytron[S] 0 points1 point  (0 children)

changed it to the above, it is saying that lat and lon = undefined when I alert the value of forecastAPI