Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BD0051836F for ; Fri, 22 Apr 2016 23:09:04 +0000 (UTC) Received: (qmail 56334 invoked by uid 500); 22 Apr 2016 23:09:04 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 56267 invoked by uid 500); 22 Apr 2016 23:09:04 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 56157 invoked by uid 99); 22 Apr 2016 23:09:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Apr 2016 23:09:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 58B0FE176D; Fri, 22 Apr 2016 23:09:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: purplecabbage@apache.org To: commits@cordova.apache.org Date: Fri, 22 Apr 2016 23:09:07 -0000 Message-Id: <7353043dc0d34316a282930dd1afcc6a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/6] cordova-plugin-geolocation git commit: Updating weather part of this readme to use a new service Updating weather part of this readme to use a new service Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/444f84ad Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/444f84ad Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/444f84ad Branch: refs/heads/master Commit: 444f84ad8e7bcc2b6ed2c54c568690875dfc6225 Parents: 2fff5f9 Author: Norm Estabrook Authored: Fri Apr 15 09:47:06 2016 -0700 Committer: Norm Estabrook Committed: Fri Apr 15 09:47:06 2016 -0700 ---------------------------------------------------------------------- README.md | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/444f84ad/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index 438026e..e7f85e7 100644 --- a/README.md +++ b/README.md @@ -345,7 +345,6 @@ function getWeatherLocation() { var onWeatherSuccess = function (position) { - // We declared Latitude and Longitude as global variables Latitude = position.coords.latitude; Longitude = position.coords.longitude; @@ -356,31 +355,34 @@ var onWeatherSuccess = function (position) { function getWeather(latitude, longitude) { + // Get a free key at http://openweathermap.org/. Replace the "Your_Key_Here" string with that key. + var OpenWeatherAppKey = "Your_Key_Here"; + var queryString = - "http://gws2.maps.yahoo.com/findlocation?pf=1&locale=en_US&offset=15&flags=&q=" - + latitude + "%2c" + longitude + "&gflags=R&start=0&format=json"; + 'http://api.openweathermap.org/data/2.5/weather?lat=' + + latitude + '&lon=' + longitude + '&appid=' + OpenWeatherAppKey + '&units=imperial'; $.getJSON(queryString, function (results) { - if (results.Found > 0) { - var zipCode = results.Result.uzip; - var queryString = "https://query.yahooapis.com/v1/public/yql?q=" - + "select+*+from+weather.forecast+where+location=" - + zipCode + "&format=json"; + if (results.weather.length) { $.getJSON(queryString, function (results) { - if (results.query.count > 0) { - var weather = results.query.results.channel; + if (results.weather.length) { + + $('#description').text(results.name); + $('#temp').text(results.main.temp); + $('#wind').text(results.wind.speed); + $('#humidity').text(results.main.humidity); + $('#visibility').text(results.weather[0].main); - $('#description').text(weather.description); - $('#temp').text(weather.wind.chill); - $('#wind').text(weather.wind.speed); - $('#humidity').text(weather.atmosphere.humidity); - $('#visibility').text(weather.atmosphere.visibility); - $('#sunrise').text(weather.astronomy.sunrise); - $('#sunset').text(weather.astronomy.sunset); + var sunriseDate = new Date(results.sys.sunrise); + $('#sunrise').text(sunriseDate.toLocaleTimeString()); + + var sunsetDate = new Date(results.sys.sunrise); + $('#sunset').text(sunsetDate.toLocaleTimeString()); } + }); } }).fail(function () { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org