{"id":64,"date":"2015-09-02T08:32:56","date_gmt":"2015-09-02T08:32:56","guid":{"rendered":"https:\/\/jongarrido.es\/?p=64"},"modified":"2022-10-13T11:19:09","modified_gmt":"2022-10-13T11:19:09","slug":"api-rest-forecast-io","status":"publish","type":"post","link":"https:\/\/jongarrido.es\/?p=64","title":{"rendered":"API Rest Forecast.IO"},"content":{"rendered":"<p>In this post I&#8217;ll explaine how to access to Forest.io Api Rest using esri.request call.<\/p>\n<p><!--more--><\/p>\n<p>It&#8217;s as simple as make the call and mange the callback function:<\/p>\n<p style=\"padding-left: 30px;\"><code>var url = 'https:\/\/api.forecast.io\/forecast\/yourapikeyXXXXX\/';<br \/>\nvar latlon = [feature.geometry.getLatitude(),feature.geometry.getLongitude()].join(',');var req = esri.request({<br \/>\nurl: url + latlon,<br \/>\ncontent: {<br \/>\nunits: 'si' \/\/ celsius, km\/h<br \/>\n},<br \/>\nhandleAs: \"json\",<br \/>\ncallbackParamName: \"callback\"<br \/>\n});<\/code><\/p>\n<p style=\"padding-left: 30px;\">The event to mange the callback:<br \/>\n<code>req.then(function(data)<br \/>\n{<br \/>\n\/\/some examples<br \/>\nconsole.log(data.currently.summary)\u00a0 \/\/ Weather summary for now..<br \/>\nconsole.log( data.daily.data[0].summary)\u00a0 \/\/ Weather summary for tomorrow..<br \/>\nconsole.log(data.currently.windBearing) \/\/ Azimut for current wind ...<br \/>\n},<br \/>\nfunction(error)<br \/>\n{<br \/>\nconsole.log(error);<br \/>\n});<\/code><\/p>\n<p>Thanks to Javier Abadia (ESRI Spain) for this demo at the ESRI user conference 2013 in Madrid.<\/p>\n<p>A simple example: <a title=\"https:\/\/jongarrido.es\/Forecast\" href=\"http:\/\/demos.jongarrido.es\/Forecast\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post I&#8217;ll explaine how to access to Forest.io Api Rest using esri.request call.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4,6,8,11],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-arcgis","tag-esri-request","tag-forcast-io","tag-javascript"],"_links":{"self":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=64"}],"version-history":[{"count":1,"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":204,"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions\/204"}],"wp:attachment":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}