Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. $("#getLocation").on("click", function() {
  2. if (navigator.geolocation) {
  3. navigator.geolocation.getCurrentPosition(function(position) {
  4. $("#location").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
  5. lat = position.coords.latitude;
  6. lon = position.coords.longitude;
  7.  
  8. api = "api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&APPID=f7dcb8e5d6a1f2126a2080a1e0d17b5a";
  9.  
  10. console.log(api);
  11.  
  12. $.getJSON(api, function(json) {
  13. $("#api").html(json);
  14. });
  15. });
  16. }
  17.  
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement