
"use strict";

angular.module('myapp')
  .controller("WeatherController", function($scope, $http){
    $scope.location = {};
    $scope.weather = {};
    $scope.cityForecast = "";
    if (navigator.geolocation) navigator.geolocation.getCurrentPosition(onPositionUpdate);
 
    function onPositionUpdate(position) {
      var lati = position.coords.latitude;
      var longi = position.coords.longitude;
      /*var url = 'https://api.wunderground.com/api/4a82154c39d11213/conditions/geolocation/q/' + lati + ',' + longi + '.json';*/
      var url = 'https://api.wunderground.com/api/4a82154c39d11213/geolookup/q/' + lati + ',' + longi + '.json';
      $http.get(url)
        .then(function(info) {
          console.log(info);
          $scope.location.city = info.data.location.city;
          $scope.location.state = info.data.location.nearby_weather_stations.state;
          $scope.location.country = info.data.country;
          $scope.retrieveCity($scope.location.country, $scope.location.state, $scope.location.city)
      
        });
    }
    $scope.retrieveCity = function(country, state, city){
     city = city.replace(" ", "_");
      
     if(country === "US"){
       $scope.cityForecast = 'https://api.wunderground.com/api/4a82154c39d11213/forecast/q/' + state + "/" + city + ".json";
     }else{
        $scope.cityForecast = 'https://api.wunderground.com/api/4a82154c39d11213/forecast/q/' + country + "/" + city + ".json";
     }
     $http.get($scope.cityForecast)
      .then(function(data){
       console.log(data);
     });
     
      
   };
  
  });
  

@@ -266,17 +266,23 @@
 date);%0A 
-%0A
+    %0A  
     func
@@ -286,16 +286,48 @@
 unction 
+startForecast()%7B%0A    //function 
 onPositi
@@ -349,24 +349,26 @@
 on) %7B%0A      
+//
 var lati = p
@@ -394,24 +394,26 @@
 tude;%0A      
+//
 var longi = 
@@ -574,16 +574,18 @@
 */%0A     
+//
  var url
@@ -684,16 +684,109 @@
 .json';%0A
+      var url = %22https://api.wunderground.com/api/4a82154c39d11213/geolookup/q/autoIp.json%22;%0A
       $h
@@ -1180,24 +1180,26 @@
 ;%0A    %7D%0A    
+/*
 $scope.retri
@@ -1676,24 +1676,26 @@
 a);%0A     %7D);
+*/
 %0A     %0A     

Update controller1.js