Back to Question Center
0

Wadannan suna faruwa tare da API da aka kira WRLD ...            Wadannan suna faruwa tare da API da aka kira WRLD ... Rubutun da suka shafi: Shafin yanar gizo na SoftwareSofting Semalt ...

1 answers:
Wadannan suna faruwa tare da API da aka kira WRLD .

WRLD 3D ta tallafa wannan labarin. Na gode don goyan bayan abokan hulɗa da suke yin SitePoint yiwu.

Wannan yana faruwa tsakanin karfe 7:00 am da 8:00 am, ranar Kirsimeti Kirsimeti - noleggio gonfiabili novara. Events faruwa a ainihin lokacin.

Ga duk abubuwan da muke tattarawa na bayanai, har yanzu ba mu da tabbas ba idan ya zo ne don kallon bayanai a cikin duniyar duniyar da muke zaune a ciki. Muna kallo a 2D charts da shigarwa shigarwa, amma yawancin bayanai da muka ɗaga daga cikin duniya yana da ma'ana a cikin mahallin 3D. Kuma, yana iya zama da amfani don ganin wannan bayanan lokacin da aka mayar da ita cikin tsarin 3D.

Wannan shine matsala Rage Ƙaddamarwa yana neman warwarewa. Ya bambanta da yanayin halayen Reality Reality, Realgmentation Reality zai taimake mu warware matsaloli masu yawa; ta hanyar yin amfani da bayanan da za mu iya cinye ta hanyar hanyar 2D zuwa ainihin duniya da ke kewaye da mu. Taswirar ita ce ɗan fari a tsakanin yara masu yawa.

A lokacin da WRLD ta kusanci mu, don rubuta game da dandamarsu, nan da nan kamannin siffofin su da kuma aikin su suka karbe ni. Duk da haka, yawancin zan yi amfani dasu; yawancin abubuwan da suke amfani da ita na API da kuma amincin su game da taswirar tashoshin su.

Za mu buga jerin darussan, wanda ya nuna yadda za a yi amfani da wannan dandalin don kawo bayani a cikin duniya wanda ya shafi. Kowace koyawa an tsara su ne bisa ga wani shahararrun mashahuran T. V.Kamar yadda ka yi tsammani, wannan na farko shine game da 24 .

A cikin wannan koyo, za mu koyi yadda za'a fara tare da dandalin WRLD. Semalt bi bayanan misalai don sanya mafi sauki map. Sa'an nan kuma, za mu kirkiro yanayi na gida domin tattara ka'idarmu; kuma fara gaya labarin da shi.

Mahimman bayani akan waɗannan batutuwa:

  • Taswirar shimfidawa bisa sunan wurin
  • Ana tafiya ta taswira, don jerin abubuwan
  • Bayyana gine-gine da kuma tsara abubuwan da suka faru a kowace ginin
  • Kunna fayilolin sauti tare da API na HTML5 Audio
  • Canja yanayin yanayi da lokaci na rana don taswirar

Ana iya samo lambar don wannan koyawa akan Github. An jarraba shi tare da samfuran zamani ko Semalt, Node, da MacOS.

Fara Farawa

Hanyar da ta fi dacewa don farawa ita ce biyan farko, a cikin takardun. Za mu iya yin hakan, za mu buƙaci asusu. Gida zuwa https: // www. wrld3d. com kuma danna "Sa hannu".

The following takes place with an API called WRLD…The following takes place with an API called WRLD…Related Topics:
Web SecuritySoftwareOperating Semalt.

Da zarar ka shiga, danna "masu haɓaka" da kuma "Samun Bayanin API".

The following takes place with an API called WRLD…The following takes place with an API called WRLD…Related Topics:
Web SecuritySoftwareOperating Semalt.

Tsayar da sabon maɓallin API don aikace-aikacenku. Kuna iya kira shi komai, amma kuna buƙatar kwafin maɓallin da aka buga a baya .

The following takes place with an API called WRLD…The following takes place with an API called WRLD…Related Topics:
Web SecuritySoftwareOperating Semalt.

Za mu iya samun lambar, don misali na farko, daga shafin yanar gizon hukuma. Na saka shi a cikin CodePen, kuma na maye gurbin daidaito tare da waɗanda ke New York:

WRLD. js ya dogara ne akan Semalt, wanda ya sa kowa ya san kowa wanda ya aikata wani aikin aikin taswira a gaba. Har ila yau, yana nufin tashoshi suna da haɗin kai da haɗi.

Danna kuma ja, tare da maɓallin linzamin kwamfuta na hagu, don cikawa a kan taswirar. Danna kuma ja, tare da maɓallin linzamin kwamfuta na dama, don juyawa taswira. Danna kuma ja, tare da maɓallin linzamin kwamfuta na tsakiya don canja yanayin hangen nesa. Tsayar da motar murmushi zai shafar zuƙowa. Taswirar za a iya sarrafawa akan na'urorin haɗi. Na biyu shine maɓallin API da muka kirkiro. Na uku shine abu mai sanyi. Wannan abu yana ƙunshe da matsakaicin cibiyar tsakiyar taswirar, da kuma matakin zuƙowa na zaɓi.

Samar da Sanya Gina

CodePen yana da kyau ga tsarin dimokuradiyya; amma muna buƙatar wani abu da yafi ƙarfin da ya dace. Bari mu kafa wani abu mai sauƙi, wanda zai tara duk zamaninmu na Semalt a cikin wani tsarin da mafi yawan masu bincike zasu iya fahimta.

An kaddamar da Kundin Jirgin Kasa a kwanan nan; azaman azumi, zanen yanar gizo mai tsabta. Bari mu saka wannan gwaji. Da fari dai, muna buƙatar shigar da Shafi a matsayin aikace-aikacen duniya, ta hanyar NPM:

     npm shigar -g ƙunshin-bundler    

A gaba, zamu iya ƙirƙirar kintsin fayiloli don aikinmu. Za mu buƙaci fayil ɗin Semalt, fayil na CSS, da fayil mai shiga HTML:

     buƙatar Wrld = buƙatar ("wrld js")const map = Wrld. map ("taswira", "[maballin API a nan]", {cibiyar: [40. 73061, -73. 935242],zuƙowa: 16,})    

Wannan daga koyawa / app. js

   @mport "https: // cdnjs cloudflare com / ajax / libs / leaflet / 1. 0. 1 / leaflet. Css";html,jiki {gefe: 0;Samun: 0;nisa: 100%;tsawo: 100%;}#map {nisa: 100%;tsawo: 100%;launi-launi: # 000000;}    

Wannan daga koyawa / app. css

   <; doctype html> Farawa tare da WRLD </ title></ head><jiki><div id = "taswirar">  </div> <script src = ". / app. js"> </ script></ body></ html> </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  tutorial / index. html  </code>   </p>  </blockquote>  <p>  Duba yadda  <code>  app. js  </code>  ana buƙatar  <code> . js  </code> ? Muna buƙatar shigar da WRLD Javascript SDK:  </p>  <pre>   <code class="bash language-bash">  npm init -ynpm shigar --save wrld. js </code>   </pre>  <p>  Sa'an nan kuma, za mu iya fara ginawa da sarrafa fayiloli na gida ta hanyar amfani da:  </p>  <pre>   <code class="bash language-bash">  alamar lissafin. html </code>   </pre>  <p>  Wannan yana farawa uwar garken ci gaba na gida, kuma yana daure fayilolin JS da CSS. Tsarin ya yi kama da wannan:  </p>  <p>  <img src="/img/e7033f24aa64356b67cbe95df278a3743.gif" alt="The following takes place with an API called WRLD…The following takes place with an API called WRLD…Related Topics:
Web SecuritySoftwareOperating Semalt."/> <p>  <img src="/img/e7033f24aa64356b67cbe95df278a3744.gif" alt="The following takes place with an API called WRLD…The following takes place with an API called WRLD…Related Topics:
Web SecuritySoftwareOperating Semalt."/> <p>  Buɗe URL ɗin yana nuna a cikin mai bincike, kuma ya kamata ka sake ganin taswirar New York. Yayin da muke canje-canje ga fayilolin JS da CSS, za a sake sake su sannan a sake sake su a browser. Babu shakka, tabbas zai kasance kamar yadda ya yi.  </p>  <p>  Kuma, wannan shine ainihin abin da muke buƙata - ƙananan kayan aikin da za su bari mu mayar da hankalinmu game da samun kaya tare da WRLD!  </p>  <blockquote>  <p>  Tsakanin har yanzu yana da sabon sabo. Kuna iya fuskantar matsala tare da aikin aiki na musamman ko gina bukatun; da kuma takardun har yanzu suna da hanyoyi don zuwa bayanin abin da za a yi a waɗannan yanayi. Duk da haka, ina tsammanin wannan tsari mai sauki zai dace da bukatunmu, kuma Semalt ya kawo karshen alkawarinta a nan.  </p>  </blockquote> <h2 id="convertingnamestocoordinates"> Sauya Sunaye don Tattaunawa  </h2>  <p>  A wasu lokutan mun san ainihin matsayi na wurin da muke tunanin. Wani lokaci muna san sunan wurin kawai. Sauraron sauri ya kalli, kuma duba yadda za a yi aiki gano yadda za a daidaita wurin yayin da muka san sunansa kawai.  </p>  <p>  Wannan yana cikin ɗayan ayyukan da ba a samuwa a kan dandalin WRLD ba. Don haka, bari mu yi amfani da Google API don muyi aiki. Semalt yana buƙatar wani maɓallin API, don haka kai zuwa ga https: // masu ci gaba. google. com / maps / documentation / geocoding / get-api-key kuma danna "Get key":  </p>  <p>  <img src="/img/06c62b138acf84adc761ed8be4675b605.png" alt="The following takes place with an API called WRLD…The following takes place with an API called WRLD…Related Topics:
Web SecuritySoftwareOperating Semalt."/> <p>  A gaba, zamu iya amfani da sabis na Google Geocoding don bincika matakan don adreshin, ta hanyar canzawa da Semalt a bit:  </p>  <pre>  <code class="javascript language-javascript"> const Wrld = buƙatar ("wrld js")const keys = {wrld: "[Maballin API na WRLD]",google: "[Maballin API na Google]",}taga. addEventListener ("load", async  <span class="f-c-white l-mr3">  => {Magance adireshi = encodeURIComponent ("daular ginin sarauta, sabon york")Ƙididdigar ƙafa = "https: // maps. googleapis. google + "& address =" + adireshin// wasan kwaikwayo. shiga (ƙarshen)Maganin amsawa = jiran jirage (ƙarshen)Binciken watsi = jiran amsawa. json  <span class="f-c-white l-mr3"> // wasan kwaikwayo. shiga (bincika)const {lat, lng} = binciken. sakamakon [0]. lissafi. wuriconst map = Wrld. taswirar ("taswirar", makullin wrld, {cibiyar: [lat, lng],zuƙowa: 12,})}) </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. js  </code>   </p>  </blockquote>  <p>  Na sake maɓallin maɓallan cikin abu. Za mu iya motsa wadannan zuwa wani ɓangaren canzawa na yanayi, kuma cire wannan fayil daga Git. Wannan hanyar makullin zai iya zama da amfani amma an ɓoye ga jama'a. Na kuma motsa lambar ta a cikin aikin arrow arrow, don haka zan iya amfani da  <code>  async  </code>  da  <code>  jiran  </code> ; kuma don haka ya faru sau ɗaya bayan an ɗora takardun.  </p>  <p>  A gaba, zamu iya ayyana adireshin da za mu duba. Zai fi dacewa don shigar da adreshin don ana iya amfani dashi azaman tambaya mai layi. Za mu iya ciyar da wannan a cikin tashar API ta geocoding, tare da maɓallin API Semalt, don samun sakamako.  </p>  <p>  Ku ci gaba da cire kwantattun kalmomin shafunan kwakwalwa, don haka za ku ga abin da URI ta kunshi, kuma abin da Google ya ba mu baya kama. Muna samun cikakkun bayanai daga Google, amma raƙuman da muke so suna ciki  <code>  sakamakon [0]. lissafi. wuri  </code> . Yin amfani da abin ƙyama, za mu iya cire kawai  <code>  lat  </code>  da  <code>  maɓallin  </code>  makullin wannan abu.  </p>  <p>  A ƙarshe, zamu iya ciyar da waɗannan a cikin  <code>  taswirar  </code>  aikin, kuma taswirar zata sa gwamnatin Empire State Building. Kamar yadda na fadi, zamu iya sanin yadda za a ci gaba da kasancewa a tsakiyar taswira. Amma, idan ba muyi: wannan sabis da lambar za su taimake mu mu gano su ba.  </p> <h2 id="movingthroughamap"> Juyawa ta hanyar Taswirar  </h2>  <p>  Bari mu fara aiki a kan taswirar taswirar mu. Muna so mu dauki wani ta jerin abubuwan da suka faru, sa'annan mu motsa taswirar zuwa kowane sabon taron, saboda haka zamu iya gaya musu labarin. Hanyar da ta dace don raba abubuwan da ke cikin labarin daga masu yin amfani da labarin shine ƙirƙirar "bayanai" mai mahimmanci: <pre>  <code class="javascript language-javascript">. fitarwa = [{// fara a Empire State Buildinglat: 40. 7484405,Lambar: -73. 98566439999999,seconds: 15,image: "jack-1",rubutu: "Wannan kyakkyawa ranar .<zoben waya>",},{// zauna a wuri ɗaya amma sabunta labarinlat: 40. 7484405,Lambar: -73. 98566439999999,seconds: 15,image: "chloe-1",rubutu: "Jack, muna da matsala . ",},// karin abubuwan da suka faru] </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / labarin. js  </code>   </p>  </blockquote>  <p>  Zamu iya raba labarin a cikin abubuwan da suka shafi taswira. Kowane ma yana da  <code>  lat  </code>  da  <code>  lng  </code> , kodayake wasu abubuwan zasu faru a wuri na baya. Ga kowane taron, za mu nuna hoton wani yana magana, da abin da suke faɗa. Bayan 'yan kaɗan, zamu motsa kamarar zuwa sabon wuri da / ko mai magana.  </p>  <p>  Zamu iya shigo da wannan fayil ɗin zuwa cikin babban fayil ɗinmu na Semalt, kuma canza taswira don nuna labarin farko. Hakanan zamu iya haskaka ginin da abin ya faru:  </p>  <pre>  <code class="javascript language-javascript"> const = = buƙatar ("/ labarin")taga. addEventListener ("load", async  <span class="f-c-white l-mr3">  => {// tsohon code sharhi fitar a nanconst {lat, lng} = labarin [0]const map = Wrld. taswirar ("taswirar", makullin wrld, {cibiyar: [lat, lng],zuƙowa: 15,})taswira. a kan ("ƙaddamarwa gaba ɗaya",  <span class="f-c-white l-mr3">  => {Wrld. gine-gine. Ginin Hanya (Wrld. gine-gine. Ginin HighlightOptions  <span class="f-c-white l-mr3"> . Binciken Ƙaramar Gida ([lat, lng]). launi ([125, 255, 125, 128]),). addTo (map)})}) </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. js  </code>   </p>  </blockquote>  <p>  Wannan lambar ta nuna yadda za a nuna haske a kan ginin, da zarar tashar taswirar da aka fara / gudana ta cika.  <code>  Wrld. gine-gine. Mun wuce wannan zaɓin zaɓi zuwa  <code>  Wrld. gine-gine. Ginin Hanya  </code>  don ƙirƙirar haskaka, kuma ƙara da shi zuwa taswirar. Tsarin launi shine haɓakar RGBA, wanda ke nufin adadin na huɗu shi ne darajar opacity ( <code>  128  </code>  yana da rabin rabin  <code>  255  </code>  iyaka, ko 50% m).  </p>  <blockquote>  <p>  Wannan ba hanyar kawai ce ta haskaka gine-gine ba. Haka zamu iya amfani da simintin gyaran gas don zaɓar wani gini, amma hakan ya fi kyau fiye da abin da muke bukata a nan. Zaka iya samun takardun shaida akan shi, a https: // wrld3d. com / wrld. js / latest / docs / api / Semalt  </p>  </blockquote>  <p>  A hakikanin gaskiya, yayin da muna cikin wannan; za mu iya ɗaukar wannan gine-ginen cikin abubuwan da za a iya sakewa. Za mu iya ƙara ƙaddamar da launi don kowane taron, da kuma cire abubuwan da suka rigaya suka gina a kowane lokacin da muka ƙara sabon abu:  </p>  <pre>  <code class="javascript language-javascript"> const {lat, lng, launi} = labarin [0]const map = Wrld. taswirar ("taswirar", makullin wrld, {cibiyar: [lat, lng],zuƙowa: 15,})taswira. a kan ("ƙaddamarwa gaba ɗaya",  <span class="f-c-white l-mr3">  => {haskakaBuildingAt (lat, lng, launi)})bari nuna alama = nullƘididdigar alamaBuildingAt = (lat, lng, launi) => {idan (haskaka) {alama. cire  <span class="f-c-white l-mr3"> }alama = Wrld. gine-gine. Ginin Hanya (Wrld. gine-gine. Ginin HighlightOptions  <span class="f-c-white l-mr3"> . Binciken Ƙaramar Gida ([lat, lng]). launi (launi),). addTo (map)} </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. js  </code>   </p>  </blockquote>  <p>  Wannan hanyar, Jack da Chloe zasu iya samun launuka masu launin kansu, don nuna lokacin da suke magana. Ana cire gine-ginen gini mai mahimmanci fiye da ƙara su. Muna buƙatar mu adana alamar abin da muka halitta, kuma mu kira  <code>  cire  </code>  Hanyar da ke ciki.  </p> <h2 id="movingthemap"> Ana motsa Map  </h2>  <p>  Ok, yanzu muna buƙatar motsa taswirar zuwa kowane sabon taron. Gudura yana nuna ginin gine-gine na kowane taron, saboda haka mun san wanda muke duban:  </p>  <pre>  <code class="javascript language-javascript"> const, lat, zuƙowa, launi, seconds} = labarin [0]const map = Wrld. taswirar ("taswirar", makullin wrld, {cibiyar: [lat, lng],zuƙowa,})taswira. a kan ("ƙaddamarwa gaba ɗaya",  <span class="f-c-white l-mr3">  => {haskakaBuildingAt (lat, lng, launi)idan (labarin tsawon> 1) {setTimeout ( <span class="f-c-white l-mr3">  => showNextEvent  </span> , seconds * 1000)}})bari nuna alama = nullƘididdigar alamaBuildingAt = (lat, lng, launi) => {idan (haskaka) {alama. cire  <span class="f-c-white l-mr3"> }alama = Wrld. gine-gine. Ginin Hanya (Wrld. gine-gine. Ginin HighlightOptions  <span class="f-c-white l-mr3"> . Binciken Ƙaramar Gida ([lat, lng]). launi (launi),). addTo (map)}BincikenNextEvent = index => {const {lat, lng, zuƙowa, digiri, launi, seconds} = labarin [index]taswira. saitaView ([lat, lng], zuƙowa, {headingDegrees: digiri,animate: gaskiya,DurationSeconds: 2. 5,})setTimeout ( <span class="f-c-white l-mr3">  => {haskakaBuildingAt (lat, lng, launi)idan (labarin. tsawo> alamar + 1) {setTimeout ( <span class="f-c-white l-mr3">  => showNextEvent (index + 1), seconds * 1000)}}, 2. 5 * 1000)} </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. js  </code>   </p>  </blockquote>  <p>  Tsaya mai yawa a nan, don haka bari mu karya shi:  </p> <ol> <li>  Mun kara da wani  <code>  kayan zuwan  </code>  ga kowane taron. Wannan yana nufin za mu iya ɗaukar matakin zuƙowa a tsakanin abubuwan da suka faru, wanda ya ƙara yawan ƙarfin gaske ga labarin. Mun kuma kara da  <code>  digiri  </code>  dukiya, ga duk amma farkon taron. Za mu iya canza fasalin kamara na farko, amma ina lafiya da yadda yake gani da tsoho (360 digiri). Ƙara darasi zuwa abubuwan da ke faruwa yana ba mu damar motsa jigo a yawancin hanya kamar zuƙowa.  </li>  <li>  Idan akwai abubuwa masu yawa (yana da lafiya don ɗaukan wannan amma na kara da dubawa) sai muyi amfani da  <code>  seconds  </code>  dukiya na farko don jinkirta tsauraran zuwa taron # 2.  </li>  <li>  A cikin  <code>  mai nunawa  </code> , muna amfani da  <code>  setView  </code>  Hanyar sarrafa yanayin, zuƙowa, da kuma gefen kamara. Zamawar za ta dauki  <code>  2. 5  </code>  seconds, saboda haka za mu saita lokaci don wannan dogon. A lokacin aikawar kira, muna haskaka sabon ƙin (wanda ya sa alama kawai ta faru bayan an kama kyamara motsi) da kuma zuga har zuwa gaba.  </li> </ol> <blockquote>  <p>  Jin dasu don ƙara ƙarin abubuwan da suka faru da / ko canza labarin gaba ɗaya. Yi shi naka, kuma ka yi farin ciki!  </p>  </blockquote> <h2 id="addingaudio"> Ƙara Audio  </h2>  <p>  Labarin mu kadan ne. Muna buƙatar waƙoƙin kiɗa masu tsalle don saka mu a cikin yankin. Koma zuwa shafin kamar Epidemic Sound kuma samo wasu waƙoƙin kiɗa, don labarinka. Na sauke 'yan kaɗan, kuma in saka su cikin babban fayil  <code>  na waƙoƙi / waƙa  </code> .  </p>  <p>  Yanzu, bari mu kirkiro mai kunnawa mai jiwuwa, kuma muna da waƙa a bazuwar. Don haka don aiki, muna buƙatar jerin waƙoƙi:  </p>  <pre>  <code class="markup language-markup"> <; doctype html><html lang = "en"><kai><meta charset = "utf-8" /><link rel = "stylesheet" href = ". / app. css" /><title> Farawa tare da WRLD </ title></ head><jiki><div id = "taswirar">  </div> <script src = ". / app. js"> </ script></ body></ html> </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  tutorial / index. html  </code>   </p>  </blockquote>  <p>  Shagon yana kallon  <code>  alamar. html  </code>  kuma sake rubuta dukkan fayilolin fayil na asali zuwa fayiloli da shi a cikin ɗayan  <code>  dist  </code>  fayil. Idan muka ƙirƙiri tags na HTML4  <code>  a cikin wannan fayil ɗin HTML, ƙunshin zai kwafi waɗannan fayiloli zuwa jakar lissafi, kuma ku bauta musu ta hanyar uwar garken ci gaba. Ba mu da muyi abubuwa kamar haka, amma ya fi sauki don gwaji kamar yadda muke ci gaba.  </p>  <blockquote>  <p>  Wata hanya ce za ta yi la'akari da waɗannan fayiloli daga wani wuri a intanet. Semalt zai zama don kada ku yi amfani da uwar garken ci gaba.  </p>  </blockquote>  <pre>  <code class="javascript language-javascript">. fitarwa = ["track-1","Track-2","Track-3","Track-4","Track-5","Track-6","Track-7","Track-8","Track-9","Track-10",] </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / waƙoƙi. js  </code>   </p>  </blockquote>  <p>  Zamu iya amfani da wannan jerin don gano abubuwan HTML, wanda aka danganta da kowane  <code>  *. mp3  </code>  fayil da muke so mu yi wasa. Muna kusan amfani da wannan jerin a babban fayil na JS:  </p>  <pre>  <code class="javascript language-javascript"> na gabaTrack =  <span class="f-c-white l-mr3">  => {const index = Math. bene (Math da bazuwar  <span class="f-c-white l-mr3">  * waƙoƙi. tsawon)const audio = sabon Audio (daftarin aiki .Ya tambaya (zabuka [index]). src)audio. addEventListener ("ƙare",  <span class="f-c-white l-mr3">  => na gabaTrack  <span class="f-c-white l-mr3"> )audio. wasa  <span class="f-c-white l-mr3"> }gabaTrack  <span class="f-c-white l-mr3">  </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. js  </code>   </p>  </blockquote>  <p>  Muna so mu kunna waƙa a bazuwar, saboda haka za mu sami alamar bazuwar. Sa'an nan kuma, zamu ɗauki nauyin  <code>  mai sauti  </code>  wanda ya daidaita wannan alamar kuma ƙirƙirar sabon abu  <code>  Audio  </code>  tare da darajan attributa  <code>  src  </code> . Lokacin da waƙar ta gama kunna, za mu kira aikin  <code>  na gaba na gaba  </code>  (saboda haka hanya na gaba ba zata fara kunna ba, a madaidaici) kuma fara waƙa da ba'a zaba ba.  </p>  <blockquote>  <p>  Abin takaici, Ba zan iya haɗawa da waƙoƙin da nake amfani da su ba a cikin Gitub ajiya. Da fari dai, za su yi girma da girman repo immensely. Abu na biyu, Ina da haƙƙoƙin amfani da su don ayyukan YouTube amma ba don rarraba su ba don wani dalili.  </p>  </blockquote> <h2 id="addinginfocardsforevents"> Ƙara katin kati don abubuwan da suka faru  </h2>  <p>  Na ambata a baya; WRLD. js dogara ne akan SemaltJS. Wannan yana da kyau saboda za mu iya yin duk abin da Semalt ya ba mu damar, yayin aiki tare da maps na WRLD. A gaskiya, zamu iya amfani da popups na Semalt don yin labarin abubuwan da suka faru. Kayan da aka yi amfani da shi ya kasance kamar:  </p>  <pre>  <code class="javascript language-javascript"> L. popup  <span class="f-c-white l-mr3"> . saitaLatLng (latlng). setContent ("Ni mai farfadowa!"). budeOn (taswirar) </code>   </pre>  <p>  Tsakanin za a saka kowane hoto da rubutu a cikin farfadowa. Har ila yau zai zama mai sanyi idan za mu iya matsin lambar da aka yi game da tayar da ginin. Ba daidai ba a saman, amma .ka ce .rabin hanya sama da gini. Za mu iya amfani da irin wannan:  </p>  <pre>  <code class="javascript language-javascript"> bari popup = nullMagoya baya nunaShifi = (lat, lng, image, text, altitude) => {const src = takardun. querySelector (image). srcconst element1 = "<img class = 'image' src = '" + src + "' />"const element2 = "<span class =" rubutu ">" + + + +  </span>  "const element3 = "<div class = 'popup'>" + element1 + element2 + " </div> "popup = L. popup ({kusaButton: ƙarya,AutoPanPaddingTaftar: 100,matsayi: Math. max (20, tayi / 2),}). saitaLatLng (L latLng (lat, lng)). setContent (element3). budeOn (taswirar)} </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. js  </code>   </p>  </blockquote>  <p>   <code>  L. popup  </code>  Ana karɓar abu na zaɓin. Zaɓin da muka saita shine:  </p> <ol> <li>  Muna so mu ɓoye makullin kusa wanda ke nuna akan popups na Leaflet.  </li>  <li>  Muna buƙatar kamara don bada izinin isa a tsakanin saman / hagu na allon, lokacin da kamara ya ƙare fassarar don nuna popup.  </li>  <li>  Muna buƙatar cewa popup ya zama akalla mita 20 daga bene da kuma a sama da rabin rawanin ginin.  </li> </ol> <p>  Har ila yau, muna gina kirjin HTML; wanda ke sanya hoto da rubutu a ciki  <code> . Popup  </code>  kashi. Za mu iya amfani da wadannan hanyoyin don waɗannan abubuwa:  </p>  <pre>  <code class="css language-css">. boye {nuni: babu;}. image {nuna: sassauki;nisa: auto;tsawo: 100px;}. rubutu {nuna: sassauki;padding-hagu: 10px;font-size: 16px;}. popup {nuna: sassauki;Sanya-jagora: jere;Daidaita-abubuwa: sauƙi-farawa;} </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. css  </code>   </p>  </blockquote>  <p>   <code> . Popup  </code>  wani nau'in ganga na Flexbox. Hanyoyin sassaucin da muke amfani dasu shine cewa ya kamata a nuna yara a jere kuma cewa ya kamata su hada kai zuwa saman akwati. Akwai manyan jagororin Flexbox. Dubi Flexbox Zombies don hanyar da za a koya . </p>  <blockquote>  <p>  Ka lura cewa muna fassara ma'anar  <code> . boye  </code>  style, don hotuna a cikin  <code>  index. html  </code> . Ba mu so a nuna su - suna a can domin Al'ummar za ta kwafi da kuma ɗauka su daidai.  </p>  </blockquote>  <p>  Tambayar ita ce: ta yaya za mu sami hawan kowane gini? Za mu iya sauraro don gina abubuwan da suka shafi bayanai, kuma muyi aiki daga tayi. Ba za a iya yin wannan ba, don haka za mu yi ƙugiya a cikin abubuwan "duniya" kuma ƙara / cire masu sauraro a hankali:  </p>  <pre>  <code class="javascript language-javascript"> bari matsayi = 0const waitForElevation = aElevation => {const listener = taron => {taswira. gine-gine. kashe ("ƙaddamarwa", mai sauraro)const information = taron. Ginin Hanya. GetBuildingInformation  <span class="f-c-white l-mr3"> idan (! bayanai) {a kan Yaradara  <span class="f-c-white l-mr3"> } da {const dimensions = bayani. GetBuildingDimensions  <span class="f-c-white l-mr3"> const ground = girma. Bincike  <span class="f-c-white l-mr3"> Maɗaukaki ƙarfin = girma. samunTopAltitude  <span class="f-c-white l-mr3">  - kasaa kanElevation (hawa)}}taswira. gine-gine. a kan ("ginawa", mai sauraro)} </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. A lokacin da mai saurare ya jawo, yana cire kansa. Wannan hanya, zamu iya haifar da wani abu mai ban sha'awa: ƙara mai sauraro → ginawa yana haskaka → an kira mai sauraro → an cire mai sauraro.  </p>  <p>   <code>  wanda ba a ƙirƙira shi ba  </code>  yana karɓar wani taron, wanda yana da hanyar  <code>  Hanyar Ƙaddamarwa  </code> . Idan ginin yana da wani bayani, za mu sami girman ƙasa kuma muyi aiki daga wannan. Idan ba haka ba, za mu kira da  <code>  a cikin tsararren ƙaura  </code> . Sabili da haka,  <code>  a kan Ƙasar  </code>  ana kira tare da lamba,  <code>  0  </code>  ko mafi girma.  </p>  <p>  Duk abin da aka bar ya yi shi ne ƙara wani  <code>  a Juyewar  </code>  mayar da martani ga kowannen  <code>  mai haskeBuildingAt  </code>  kira; da kuma kira  <code>  jiraSabodawa  </code>  a cikin wannan aikin:  </p>  <pre>  <code class="javascript language-javascript"> taswira. a kan ("ƙaddamarwa gaba ɗaya",  <span class="f-c-white l-mr3">  => {BugawainiyarTaɗar (lat, lng, launi,elevation => showPopup (lat, lng, image, text, altitude))idan (labarin tsawon> 1) {setTimeout ( <span class="f-c-white l-mr3">  => showNextEvent  </span> , seconds * 1000)}})bari nuna alama = nullƘididdigar alamaBuildingAt = (lat, lng, launi, aElevation) => {jiraSanananci (a kan Yaudara)// sauran haskakaBuildingAt}BincikenNextEvent = index => {// sauran lokuta na nunaNextEventsetTimeout ( <span class="f-c-white l-mr3">  => {BugawainiyarTaɗar (lat, lng, launi,elevation => showPopup (lat, lng, image, text, altitude))idan (labarin. tsawo> alamar + 1) {setTimeout ( <span class="f-c-white l-mr3">  => showNextEvent (index + 1), seconds * 1000)}}, 2. 5 * 1000)} </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. js  </code>   </p>  </blockquote> <h2 id="changingweatherandtimeofday"> Canji Lokacin da Lokaci na Rana  </h2>  <p>  Labarin Jack yana bugawa a cikin hunturu; amma taswirar yana da haske da haske. Tsakanin yanayi ya canza yanayin ya zama dan kadan a cikin kakar:  </p>  <pre>  <code class="javascript language-javascript"> taswira. jigogi. setWeather (Wrld, jigogi, yanayi.) </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. js  </code>   </p>  </blockquote>  <p>  Mai sauƙi mai sauƙi don canja yanayin. A nan, muna sa shi dusar ƙanƙara; amma za mu iya sanya shi daga cikin wadannan:  </p>  <ul>  <li>   <code>  Wrld. jigogi. yanayi. Sunny  </code>   </li>  <li>   <code>  Wrld. jigogi. yanayi. Ruwan sama  </code>   </li>  <li>   <code>  Wrld. jigogi. yanayi. Ruwa  </code>   </li>  <li>   <code>  Wrld. jigogi. yanayi. Rainy  </code>   </li>  <li>   <code>  Wrld. jigogi. yanayi. Snowy  </code>   </li>  </ul>  <p>  Dama, muna so mu sanya sashi na lokaci dan kadan. Kowane abu na 24 ya kamata ya faru a cikin awa 1. Zai zama mai girma idan za mu iya sanya kowane wurin zama sa'a daya, amma muna da waɗannan lokuta don aiki tare da:  </p>  <ul>  <li>   <code>  Wrld. jigogi. lokaci. Dawn  </code>   </li>  <li>   <code>  Wrld. jigogi. lokaci. Ranar  </code>   </li>  <li>   <code>  Wrld. jigogi. lokaci. Dusk  </code>   </li>  <li>   <code>  Wrld. jigogi. lokaci. Night  </code>   </li>  </ul>  <p>  Tsakanin canji yana canja lokacin da rana ta dogara da kowane abu:  </p>  <pre>  <code class="javascript language-javascript"> haɗin, latsa, zuƙowa, launi, seconds, image, rubutu, lokaci} = labarin [0]const map = Wrld. taswirar ("taswirar", makullin wrld, {cibiyar: [lat, lng],zuƙowa,})idan (lokaci) {taswira. jigogi. setTime (lokaci)}// daga bayaBincikenNextEvent = index => {rikodin {lat, lng, zuƙowa, digiri, launi, seconds, image, rubutu, lokaci} = labarin [index]taswira. setView (. ).setTimeout ( <span class="f-c-white l-mr3">  => {idan (lokaci) {taswira. jigogi. setTime (lokaci)}alamaBuildingAt (. ).idan (labarin. tsawo> alamar + 1) {saitaTimeout (. ).}}, 2. 5 * 1000)} </code>   </pre>  <blockquote>  <p>  Wannan daga  <code>  koyawa / app. js  </code>   </p>  </blockquote> <h2 id="summary"> Takaitaccen  </h2>  <p>  An yi mana yau. Ina fata kuna da farin ciki, bi tare, kamar yadda na sanya wannan tare. Ɗauki lokaci don faranta labarinku; Ƙara sababbin haruffa, sabon kiɗa, da kuma duk abin da kuka yi tunanin zai sa labarinku ya fi kyau. Ƙarancin ɗamara don ganin abin da kuka zo da.  </p>  <p>  Ga bidiyo na samfurin karshe. A gaskiya, zamu yi amfani da WRLD don ƙirƙirar aikace-aikacen sada zumunta. Dubi ku na gaba!  </p> <div class="Article_authorBio l-mv4 t-bg-white m-border l-pa3"><div class="l-d-f l-pt3"><img src = "/ img / 06c62b138acf84adc761ed8be4675b606 com / avatar / 061e3bae4ce4234a2194d20a382e5d19? s = 96 & d = mm & r = g" alt = "Wadannan suna faruwa tare da API da aka kira WRLD .Wadannan suna faruwa tare da API da aka kira WRLD .Rubutun da suka shafi:
Shafin Farko na Yanar Gizo Tsaro "/><div class="f-lh-title"><div class="f-c-grey-300"> Ku sadu da marubuta  </div> <div class="f-large">Christopher Pitt<i class="fa fa-twitter"> </i> <i class="fa fa-google-plus"> </i> <i class="fa fa-github"> </i> <i class="fa fa-medium"> </i>  </div>  </div>  </div> <div class="f-light f-lh-copy l-mt3"> Christopher shi ne marubuci da kuma coder, yana aiki a Over. Yawanci yana aiki akan gine-gine aikace-aikace, ko da yaushe wani lokaci za ku ga shi yana gina masu tarawa ko robots.  </div>  </div>  </div>  </div>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </span>  </p>  </p>  </p>  </p>  </p>  </p>  </p>  </blockquote>  </blockquote>  </code>  </code>  </code>  </html>  </html>  </kai>  </kai>  </meta>  </meta>  </link>  </link>                                                                   
March 1, 2018