I know, I knowyouhaveseen a 1,000,000 weatherapptutorialsbeforeThey'reallovertheInternet.
Butinthisweatherapptutorial, I'm goingtobedoingonethinginparticulardifferently, thatnoneoftheothertutorials I seedoAndthiscoulddowntheroadpotentiallysaveyou a tonofmoney.
Somakesureyoudon't missthat.
Let's getstartednowwasquick.
Take a lookattheapplicationwe'regoingtobebuilding.
Now, togetstartedwiththisweather, weneedtohavesome A p I toaccessinordertogetboththeweatherinformationaswellasthislocationinformationdownhereforthedifferentplacesonEarth.
Sotogettheweatherinformation, we'regoingtousethedarksky a p I Allyouneedtodoiscreate a simpleaccountonhere.
It's easyandfreetodo.
Andhere's alltheFBIdocumentationweneedAndtheimportantthingyouneedfromhereisan A p i keaswellasthedocumentationonwheretocall.
Andtheonecrucialmistakethatmostpeoplemakeistheytakethisap I keandputitdirectlyintotheirJavaScriptontheclientside.
Andtheproblemwiththatis, ifwegobacktothedocumentationandscrolldown a littlewaysthis a p I ifyousignupfor a paidaccount, willactuallychargeyouforthenumberofrequeststhatyoumakeafter a certainamountoffreerequest.
Soifyouputyour A P i p intheJavascriptitself, thenyou'regonnabeopeningyourselfuptosomeonestealingthat a p i keandusingitfortheirownmeanswhilechargingyoufort.
Andthisis a mistakesomanypeoplemake.
Soinourvideo, we'regonnamakesurethatweputour A p i keinsideoftheserversothatnoonehasaccesstoitexceptforusyouthinkwe'regoingtoneediswe'regoingtoneedtousetheGoogleis a P I.
Whichiswhat's populatingthislittlelistdownhere, whichisgoingtobetheGoogleplaces a p I.
It's quite a bitmoredifficulttosetup, but I'm gonnawalkyouthroughallthestepsneededwhenwegettothatpoint.
Httpmoduleandalsowewant a fewdevelopmentdependencies.
Sowe'llsaympm I dashdashsaveDev, Thesewillessentiallyonlybeforonewe'redevelopingandwewantDottieEnvytoeloadinour a p i keaswellasnodemontoeautomaticallyrefreshourserverforus.
Nowthatthoseairdone, let's setup a simplescripthereinordertorunourserver.
Sowe'regonnasayappthatuseexpressThetIQandthisstaticisjustgoingtobeinsideof a publicfolder.
Thisisjuststandardpracticetousethepublicfolderhereandour a p I isonlygoingtohave a singleendpoint.
So I'llsayaptoutpost.
Andwewantthistobeourweatherendpoint.
Thisisgoingtogetourweatherforusfromthedarksky, a p i andagainlike I mentioned, thisiswhere a lotofpeoplemessup.
Theyactuallyputthisinsideoftheirfrontend, whichmeansthat a P I keisexposedtoanyonethathasaccesstotheJavascript, whichisanyonethatknowshowtousethedevelopertoolsinsideofthebrowser.
Sowe'llsaywink, a tripisgoingtoequalthatstylesNaziSS.
Andweneedtotellthebrowserthatthisis a stylesheet, sothatknowshowtoactuallyparsethisdata.
Andlastly, wewannahave a scripttagherewhichthesourceisjustgoingtobeequal.
Scriptout J s closethatoffandmakesurethatwedefer.
Thisisthatit's goingtoloadafter a pagesdonerenderingnowinsideofthebodyhere, wecanactuallydothecodeforourweatherout.
Solet's take a lookatwhatwehave.
Asyoucansee, wehave a containerherewhichcontainsthisheadersectionwithaniconaswellastheinformationforourstatuslocationinallofthedifferentdetailsofourweather.
Soit's goingtogive a classhereofcontainerClosethatoffandeverythinginsideofherefirstthingwe'regonnahaveisourheader.
Soagain, whatifshe's a deadforthis?
Giveit a classsetthatequaltheheaderAndtheonlythingthatweneededsaidofourheaderistheiriconiconisgoingtobeinsideof a containeragain.
Whatiscalledthisiconcontainer.
That's becausewehavethisnicewhitecirclearounditandouricon, we'reactuallygoingtobeusingcanvaspoorbecausewe'regoingtobeusing a librarywhichwillimportericonsandthelibrarytakescanvasicons.
Now, insteadofthisdetailsection, we'regonnahave a bunchofdifferentdetailsandwe'rejustgonnagivethem a genericclassofdetailsowecanshareallofourdifferentstylesbetweenthesedifferentsections.
Andeachoneofthesedetailsisgoingtohave a diffwith a classoftitlejustlikethis.
Andourtitleforthe 1st 1 isgoingtobewind, andthenwe'realsogoingtohave a diff, whichisthevalue.
Sowejustgiveit a classhereofvalue, andthisisjustgoingtosaytobedeterminedas a defaultvalue.
WeneedtousetheJsmaps, solet's seeifwecanfinditbytypinginJavascriptormaybemaps, mapsandtherewegomapsJavaScript, a p I.
WealsoneedthisenabledsothatwecanusetheGoogleMapsjobofscript a P I.
Assoonasweenablebothofthose, weneedtosetupin a p i ke, whichwecanuseinsideofourJavaScript.
AndnowthisAPikeyis a littlebitdifferentthantheother a p I casesthatwe'vebeenworryingaboutbecausewecanactuallysharethisap i keinourpublicJavascriptbecauseit's notanythingthatwecangetchargedfor.
Soinordertosetupthat a pikey, wejustgointothistextboxheretypeandcredentials.
Andwewantonlytheplaceis a p I andthemapsJavaScript, a p I thetwothatwejustenabled.
NowwecanclickSaveandthisAPikeywillonlybeabletobeusedforthosetwoparticularAPeyesthatwewanttousenowwith a p i kesetuplastthing, weneedtodoislookatthedocumentationtosetthisup.
Todothat, we'regoingtogototheplaceis a p.
I clickonthatscrolldownuntilwefindthedocumentationandwewanttomakesurethatwelookattheJavascriptdocumentation.
Now, ifwesaythatweareoverloadingintheJavascript a p I thatweneedinordertousethatdropdownlist.
Now, withallthatboringstuffoutoftheway, wecanfinallyjumpintothefunpartofthistutorialwhichiscreatingtheactualjobscriptthat's goingtocallthiswhether a p I forestsandreturntheinformationtogetstarted.
Soifitisequaltoknow, allwewanttodoisjustreturnbecausewecan't doanythingifwedon't have a place.
Now, wheredowechecktomakesureourplaceexist?
Wewanttogetthelatitudeandlongitudesoandthereasonwe'redoingthisisbecauseifwelookatthedocumentationfordarksky, scrolldownjust a littlewaysHereyou'llseethatweneedtohaveboththelatitudeandlongitudeinsideofourcoal.
It's actually a functionandwecouldbethesamethingforthisOneisdotelegyforlongitude.
Makesurehetypedthatoutandyoucangetalltheinformationonallthedifferentmethodsandpropertiesthatthisap I returnstousbyjustlookingthroughtheGooglesap I documentationrightherefortheplacessection.
Butsince I alreadyknowwhatitis, thisisallwereallyneedtoworryaboutforgettingthelatitudeandlongitude.
Nowwecandothefunstuffwhichisactuallycallingour a p I whichwecreated, whichisslashweatherandsendingitthelatitudeandlongitudethatweneed.
Inourcase, thisisgoingtobe a postmethodbecauseinourserverwesetthisupasanappthatpostnextwewanttosenditthedifferentinformationwe'regonnaneedforourheaders.
Sowe'rejustgoingtosaydotcurrentlyandthisisgoingtobethesectioninsteadofourcode, whichisthemostuptodatecurrentinformationfor a budget, latitudeandlongitude.
Andifyouwanttogetallthisinformation, it's ofcourseavailableonthedarksky, a p I, aswellasinthecouncillongthatweprintedout.
Next, wehaveprecipitationdottextcontent, andthisone's goingtobe a littlebitmoreconfusingbecausewewanttoconvertthisto a percentagebecauseitactuallyreturnstous.
WecouldjustgooverheretotheCDandJsforSkyecon, andwejustwant a copyofthisMinifiedversionhereisjustgonnabeslightlysmallergoingtoourindex.
Andofcourse, wejustwanttoputthissomewherebefore a normalscripttag.
Sowe'regonnacreate a scripttagforit, makesureit's differandwewanttosetthesourcehereequaltothatsource, andthisisjustgoingtopullinthatskyConslibrary, andwecancheckoutthisguyKhandocumentation.
Solet's justsearchforthat.
We'llgoinhereforSkyeconsand, asyoucansee, isreallystraightfordocumentationforhowtosettheseupgrown a creativevariablewhichiscalledIcon, whichwe'regoingtosetequalto a newskycon.
Andinsteadofhere, wecandefinethecolor.
Inourcase, we'regoingtobeusingthecolorhere, whichisjusttoo, too, toowasjust a reallydark, greatcolorforus.
MakesurethisisactuallyskyconsinsteadofScottCaan.
Andnowwehaveaniconandwecanactuallysetanduse.
Solet's dothatdownhere.
Wejustsay I conductset.
Thisiswherethe I D thatwesetonourcanvaselementwent, Asyoucanseeherearecanvashasanelementoficonasan I D.
Soweusethatexact I d insideofthissethereandjustwanttotellitwewantittobedatadoticonbecausethisdarkskyFBIreturnsthestringoftheiconthatweneedtoset.
Inordertodothat, we'regoingtousedisplayflex, whichis a reallyeasywaytomake a centerthingssowecansetthejustifycontenttocenteraswellasthelineitemstocenter.
Butweneedtomakesurethatourpagehasatleast a minimumheightof 100.
Nowtomakestylingeverythingreallyeasy, we'rejustgoingtodo a nicelittletrickthat I dooneverysinglepagethat I workon, selectallofthedifferentelementsonourpagebeforeandafter.
Andwewanttosettheboxsizingtobeequaltheborderbox.
Andalso, I'm gonnasetthefontfamilysoitlooks a littlebitnicer.
Because, asyoucanseehere, if I expandthesizeofmyscreenat a certain 0.1200 pixels, it'llstopgettingbiggerbecausewedon't wantittobecomemassivelyhugeonbigscreens.
Sowehavethatmaximumwithhereof 1200 pixels.
Next, wewanttosetthebackgroundcolorsothisbackgroundcolorsjustsimplygoingtobewhite, verystraightforwardandalso a boxshadow.
Now, Boxshadows a fairlydifficultpropertytoworkwith.
Also, ifwe'regoingtogive a littlepaddingaroundthissothatnothingistooclosetoeachothernow, wecanstyletheactualstatus.
We'regoingtogiveit a fontsizeflips.
Makesurethat I actuallyputthisinsideofhere.
Fontsize, we'regonnausethreeareIan, andwe'realsogoingtodo a fontweightofbold.
Nowlet's gobacktoourweather.
Havetorefreshthat, andthat's lookingperfect.
Wecandoessentiallytheexactsamething, butthisisgonnabeforourlocationinsteadonourlocationisdoingtohave a funsizeoftwo r e m offun, weightofnormal, andwealsowant a littlebitof a marginonthetop.