Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- var loni;
- var lati;
- // getting the latitude and the longitude of the location
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(function(position) {
- $("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
- lati=position.coords.latitude;
- loni=position.coords.longitude;
- });
- }
- //getting the JSON from the API
- $.getJSON("http://api.openweathermap.org/data/2.5/weather?lat=" + lati + "&lon=" + loni + "&appid=31295830df05b399a4085f7383e6e75f", function (data) {
- //accessing the JSON
- var weather=data.main.temp;
- });
- $("#weather").html(weather);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement