Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. $(document).ready(function(){
  2. var loni;
  3. var lati;
  4. // getting the latitude and the longitude of the location
  5.  
  6.  
  7. if (navigator.geolocation) {
  8. navigator.geolocation.getCurrentPosition(function(position) {
  9. $("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
  10. lati=position.coords.latitude;
  11. loni=position.coords.longitude;
  12.  
  13. });
  14.  
  15. }
  16.  
  17. //getting the JSON from the API
  18.  
  19. $.getJSON("http://api.openweathermap.org/data/2.5/weather?lat=" + lati + "&lon=" + loni + "&appid=31295830df05b399a4085f7383e6e75f", function (data) {
  20. //accessing the JSON
  21. var weather=data.main.temp;
  22.  
  23. });
  24. $("#weather").html(weather);
  25. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement