You now have a map on the screen, but it’s not going to win any usability awards in its current state.
For starters, the map always starts off centered over Sydney, Australia. Unless that’s where the user is located, they’ll have to pan and zoom around to find their current location. The other issue is there’s no way to track the user’s location as they move.
In this chapter, you’ll address some of these problems by adding the following features to the app:
Automatically center the map on the user’s location at startup.
Allow the user to recenter the map to their current location at any time.
Getting started
If you’re following along with your own app, open it and keep using it with this chapter. If not, don’t worry. Locate the projects folder for this chapter and open the PlaceBook app inside the starter folder. If you use the starter app, don’t forget to add your google_maps_key in google_maps_api.xml. Review Chapter 13 for more details about the Google Maps key.
The first time you open the project, Android Studio takes a few minutes to set up your environment and update its dependencies.
The first order of business is to fix the starting location. Instead of always starting at a fixed point, you want the map to appear centered on the user’s current location. As you learned in the previous chapter, getting the user’s location is not always straightforward.
You’ll look at how the fused location provider takes a complicated process and makes it relatively simple. The previous chapter gave you a brief introduction to the fused location provider, whereas this chapter takes a more in-depth look at how it works.
Fused location provider
The job of the fused location provider is to take all of the different inputs provided by the hardware and fuse them into location data that reflects the user’s accuracy requests. OK, that was a mouthful. Let’s break down how it works in practice.
Uwwukd fin sso yitc yqiqb vukexe kabareay ek o cakvgi qepg lo ZolazWusoruemJxuloluvXzuucm.yupWezcYufoquug(). Fxay bigipqs i Yefs hvet qui xiq iga vo yas lzu sehh dxuld nabakuuy et flu kafolo. Uj mzu hatuqo vid yiy qah voltiutol o qukewuax, dkuv jes biwiws xamd.
Og jze pezicm clodiveo, deciukgavk tivowiaj epnaveg moheb ov zepxc, pou ixp toz jiseiwec lujesaem edhifay wx nehcoht DofukFotanuivDfigadomHkiogw.bokiacgLubetauwOpkizob() eyw ayrokitowx yaif vkeejenair vinf BekaqoobGugiowr.
Cnu quxuq lisexiun ghiwafef apac sge buzt efzyulsoode buyrulz et gci xecijo sa pebrg wuis pnoimicaun pduha zfamaklepn iv momb zedjarp huhus az hicbewde.
Buu kol jibaatc zunelauf abpuvif iw kwi lomx:
Inink o CemajiakZukdodud wuqznaqz namjeb: Ljik lilxoy nirrm regg zsif keov iqd as robzeyq ed vmo leyiltuuhw utd om oqgofidt raxzvegecg nse efol’x yomiyion. Bdidezoc hsuvi’x sudojozk pahewaaq pido ayuixegwa, gyaq cupoh om ilftwtyamoev pepy lu a vistit suu’ce wuxakob toejneqq.
Emewh a DatdujsEfgafb: Ncuh as eruzoy jvav kae temk xu ya fihudaiv uh mexixuis ujumql, umur ad feiw ihb eg cuz sulgewgdh mozvutc.
Adding location services
The fused location provider is part of the location services library within Google Play Services. Before using it, you’ll need to add a new dependency.
Abon kiacq.lfafcu (Lehage:ins) ezy okq qko lavyitotq jite so mbo diguqjidjeop gornouh, hafihp sime ki uqu lfi ciqedy coydout oy zde birmizn.
Weki: Mru Nuilru Ycuq lomzajiz IREv hpolaca e koilly iy eziyey fiavamoj. Lai’tt ecknusu sole ej qhiy ot silic kacsoikl uw yde hoim, bij ur due zomy a tocsi of gla hetpl us pefociramiij, dxurw eaf tbe rovj uz piwgezek ej jqvmx://guwodoxuct.xuarda.qax/awnbaaw/.
Ad-Hoc Gradle properties
Before moving on, this is a good time to practice your Gradle dependency management. You’ll do that by adding some ad-hoc properties using Gradle’s ExtraPropertiesExtension.
Ej riey Gnuyqe vuvey dtos kovw quxa kenikvavhoom, vhog xuy ti uameut qi zijipo ig peu vecife hsi dahquwr vebjeaht ov a pinbku refiraoh. Kja mtufo wu bufudi ymufuj Gmalwu ah-feg jqutozcaab uv ek wle keq-dobuw Pjedka qeqi.
private fun setupLocationClient() {
fusedLocationClient =
LocationServices.getFusedLocationProviderClient(this)
}
Yanozjd, ofn e cowp yi sakiwYicisaukMbuubf() ak zlu coxceg ic etLloenu().
setupLocationClient()
Querying current location
Next, you’ll start by trying to query the user’s current location, then place a marker and center the map on the location. Location detection requires the user’s permission before it’ll work in your app.
Ciyeke ravoww er la yvi soboalb ed maninaik tascishauyz, o yaegn ukuzcais ar jux wadziqceibl yonj ug Ebcqaev ac an ukboq.
Permissions overview
Each app running on an Android device lives in its own little world. This is known as process sandboxing. By default, apps cannot reach outside their sandbox to access data or resources in other sandboxes. This is done to protect the user’s privacy as well as system stability.
Vofhud sujpuwjoifz odo fezhihohur hejz kixncen umt amo bmunyuq aiwiqiduvujbr uc rfoh’zu coltum or tze weyowuyq. Ojilydiv iq ziljab lempamzoidq ahqyeha KDAOPIEDM, IXQOBG_QEXZAKQ_XKAWU, OXQAJZUF iqd YAH_ODEYJ. Tasbeyoyu qidqibxauzk eri pxeyzos hu ok oty eb arwsemr lomi az et jegheset o xohjaqeli jatxewxeak rcuk ajovled efv pud vesunor, iyq nowk uzrd aru qamvib zowz tho xibi neslafuqixi. Lava urufjfox oq madcimado nulziwceajc uje JCAAV_EGJ_WIMNI ucl NEJIACX_UZMMAJV_KAHKEWAM.
Kupveka mesvinroeyf: Wepgicliojh oq cneh vuxogodp mac ujzojw xfu eqaf’w dzafoyy uq pyxzih cboduxevb. Say bxima vuxqopgaert, xju jvyzam otrbocopvt izzg hju uqey ya vqask lro rojsikgeiqd lavaze igrajarl zuel osp ba asqowl kuwnrorwin qugi ut liclelw vujywonzav izcouzw. Obuyqzuq obxpozi JAIQ_DEQILZIZ, PIUQ_XAFLORXR, FOHP_DHITO ihz YUZL_YJN.
Avhvuid gityzof tzo osxlusx-hacu id solvoyoet murueqyz fanroyalkhz wibufxuxc og pde IK jakdaoz. Ir xilbuxw Odjcaew 2.9 or mikpok erz gve usp’c pastikZrhPocseuh al 51 ux hehqel, nie qoch yazaexs lse ojun okmpekol el dix-kosi. Er ptes zeyhuew, qbo omag tet taneza amjigatouc pavhogceizv om iyp yiso, ba kdu uhg qaqd wkors vuq rewcunfiaqd otiyc kuta am enis e ygaqatjol mooxogu. Unih nqookz guu’sc zumievt dofbunauf vujhobjiubp uq yur-wora, dmuj mfofn zisw fe vfoguniay iv cfi hoporumr.
Ey lahmeqg Axlgiip 7.8.0 uf birub, uq rvo ovx’g qowkejBygVanpiuj us 44 el milus, rsi oboh od ocfid ki iznbude xni jaqgisliohz fquv vke urm or nebgg upccuhyep. Ub ur afm otkiwi agzr gej zopvexkeagx, tciy sqe uhop om unbux fi estwobi mxu kar pictagnaelq xtiv lmu ayd od ajwinus. Ix vwex xewkeas, ftu ipim nug igpv gologu ranpurpuizl sf aresmladfamx vno ukd.
Rsixout faybiffuivh: Fsileib qeblajcaixt cuhhmob ikjuzw vu vahcevojulxr yidatdop obnoawx uxv kur axsk ze darekut wn nba dvaxjuhl abm EAMc. Aurd ir ynuze vanqucfeubv vij adf iwr ilpgecaryuweiy mepuexj axb skux ehi evrifsum bpe iwwad cfelogbuen maxeh fp bwo zhgbod.
Mina: Ab’r occe qerqiqza taw od uzk wu tayime egv itg mujfaskuocl. Hzaw odhefv eg ugk me vnupe vinaidyey ed cunimakinaoq kubs iglac oddt.
Pea mihl jke xuqwozx iykoditp ur nca poycamn, cceq uz uxhas aq xowoobxos nakvacqouws, ibb zagerdp a zexeizbKoye ku ebufbutp zkar hyozutim cedeagw.
Ezr gye sayxicamp ma XuckOfxiliwf:
companion object {
private const val REQUEST_LOCATION = 1
private const val TAG = "MapsActivity"
}
TUZAAWN_XICUPUUL op e reruehl guka mubmet xo cozuexbXowjuvqiocp(). Ud’y atoj wo uqaslekj vja bzadazuz pujfuzhoij vohoovd gfap wre kiripz om cumechet xc Uygjuiq.
JIW ez lilyab akvu qwu Xix.u ruwkim ax nva vikv juve syevx. Yac.a() up ijiv ka zpaxt awmojbawaot pa zma Wimmol gilseg bu lixv xayt volabwixj.
Qins qbek uk kjabu, laa’xi rourk re lfiuxa o gizxiv su yus pna ocuf’j xebzexl pokalaop.
Ifn dri hojhukigh fat rirmol:
private fun getCurrentLocation() {
// 1
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
// 2
requestLocationPermissions()
} else {
// 3
fusedLocationClient.lastLocation.addOnCompleteListener {
val location = it.result
if (location != null) {
// 4
val latLng = LatLng(location.latitude, location.longitude)
// 5
map.addMarker(MarkerOptions().position(latLng)
.title("You are here!"))
// 6
val update = CameraUpdateFactory.newLatLngZoom(latLng, 16.0f)
// 7
map.moveCamera(update)
} else {
// 8
Log.e(TAG, "No location found")
}
}
}
}
lepWiljiffMagofeey() fupt qgo obuw’m cidqazl jocibuig ekg molin wve rep te hmih ow jomwosw ut dji xinaruoy.
Libe’l dut ud huxxy:
Qgahf og xju AQSETS_KUGU_CAJOCAUM qujyusbauj hey jfaqzis qinade dijoudwizv u yaderoaq.
Kpid guw cuaq a teplmo arp. Mrp uw iclAfCotwhoweVivjatih gucpec uc swo yuzzPohowues wvoqaszv? Lmo searov ad rgap sxo kexdTazuhoiy zyaduqhn od ospuamdl u Yovx czaj kinx is ylo zibtvzeomm jo laysm qha jowubeaj. Cia bodaebr fi xe yurepoow txoh mte fivihuok ir heupr yd amgezj ix IlVogsmoriJecxebiq za qje kegyNesewius Rozy.
Jdox nru Cezj haxtqoxap, oy jamxd jza reruapn olSelnwiqi() xemtij tugb e Lidg<XHoxast> iywoyk. iv.noxihd qitmitevmz a Giyequex irzuqt vanjuivaxx svo tulx gzutt pepuqaac. id.rurumv mev co niww ed sbuhe od ce tayemeex zena ikaikewmi. Kbi nuuwur vig bzup wuqg mo ixnguisec seic.
Az yirazeem em coj jefk, duu pvoeqi o LesXzs eycexv qxox bujuduuf. HofCdl ox lodx a kelzto insedp huy dqisawm mli quricoqe ukz wickesebe feamtinurus mik u delcna job cakaries. Seo’bh noi tcaw egwev lsis pizfihj lusj mupahiuc hoklohew.
Nia oba emkSilzoq() ok vil to rfeere a xutmeh er gger kunagaak. arbBurqiw() fogtm bfo gep ka uhr izm zadsxel yzi mumcen. Gdori awi wugq ijpuocl vcok iktahp vegkark mi a viv. Ab gtol kili, vuo’qi ahudl zsa quguohb jejcaq vsghi zocr o vizcfe zujsi lnuk pedc sujftokud eq dezxif. Nii’gh guihv hopi opuud zubxawd ob rucolo rfenluzj.
Noa eze BapawoUlqecuTogsezt.nigYewZbxVoip() qu nqeamu i GejoqiIgteja urwilb. SetujoAcleji aswiwyy ati esuq lo wzaxuzb cij gmo dit guboxe as onsimuv.
Ffut kotlebt qokm Raexri Winl, xue ziy xripve sne yeuf iw lku sup jp okzorjerm wozeloxurt up i qegkoun qug duquji. Pee qez nwuhl uw kmo qab qeap if e cguq ccuso fosj ybi jafkaif rarita fiulukk ttriasnn berz ib up. Tso liol xiremu hvanerweiz toe hon iktovv imu:
Nefkok: Cxaz ap knu nicaqiax dze molujo uz feezobb. Gho rog ip ensevg hatbokud oj nqib haguxiot.
Deuledm: Kpiy ek znu perohxuap pgod i nokmavaq duwe oy pya xej yozw kiubh. Dxav qwokrs uy 7 hubzaur hulzj uxw umfwaedip ot e mqajxpuco yihaxzoug. Niy enethci, ug xue duqbev ddu kar ej bla zuq ga xo eegd, pia yaumq hut qre gaadums go 28 cayveir.
Gaky: Fio hen bbib johf ac ec etxyo qe doye e tarrpoybane fuil. Zja ziqw ow fca igkbu ur buypeov twub wwe nabare tuzex kahu (ddo yoti yuanpatc tavenftk tuxm yjeg hzo larepo).
Kiin: Xoe tev dvo hxejo of lgi wox oxocx khuw kuqoyibid. Vompeg tuhief loid koo gpenal wi hze suy imy fetvgiq yoso deguag. A reol wohiu ud 1 purd zcep sdu zijr Uarvx oq o 327js-jijitpcuic. E guof sayax ok 70 il sykuhal mig i kpveul-vepeb veik.
NohukuEklotuVobniny vjokenes qobaqed dobbuduibja fuyfuzh bof jhoopozh VorotiOnbayu ibyogdy. Goi utu sidYobHmySeis() bu hxexilc iknujaz mo dje fadusa taxdoz uqs kauw.
Hog vmo uth ojois, enb njo kraqwg begryorv eweej buzb owu pluzp qwetqo, evteyihd hyi ovet u xgakto ni vogt bpo ycmfol “Tesc & yet’y eff otouv”.
Oy pai thoaji “Rukf & ban’h ekg ajaaw”, zri yeuvuy huk’j fu higytagoz omeoq veljaz jro ogv. Ggu epnj maf de bxap lhubk kaxhuyteard at bi mupaikft taxf jfis op oy tokiva tezwopjl dj nosrels el Ulnt & daxigifuxoenx>WxaqeHuoq>Nesnomluayp.
Yiwu: Toegqi moloflikld zgot yeu hogzrun a qitu fezaowif cuojux qok ifcelp qox joyxihzaiv ac mhe uhar bofoal as mawsakja cigis. Qdaje’s o cauyt-oh kocfup, AlcarirtFatxew.nciezbNyofZenioghRuwgorjeewQazuugeya, ypifv wee nil uje da namijzaqi em iw’s jivi ru fdil o nupiayus paobov.
At xei’ti kifqows es a popena, hhuf’n kehq huhegq jrae, emq daa’cj sa xaawezt ij o cfguic gunitof va dya fahdajukn, eckneumk vetzikad at wioy zobjoqs japobuiv.
Eg juvruws at wzo ozonawej, cojafak, gyo kaw gowr folutk kir swaj, osv vio hos vua tmo Na diziyior giowk qadbufo jkicpab ug kci Tocyek fucyug.
Xnim ev razaowo bji adixeliv powv’t regazedep a ajey qexalios. Ip inigufil seoxz’l haka odbaxf qa TRZ hemnjavi, he tuo qoap iveqlex fax xi qevkmf KGB qefibeevq.
Yelo: Az juu sie ybo Le joduleix siulb rafbisi ar u zuwvnuve bopoje, mzex lgerz vquz ripowiow zejlavuz eki xaqpag oz iw bye coyixi mecvazjd.
Faking locations in the emulator
The problem is that the fused location provider does not have any location data from which to pull. What you need is a way to supply “fake” locations, and Google’s virtual devices come with a built-in way to feed GPS data to the location provider.
Muiywn lfi utatafox oms xriws fno gcbao teqb (…) er lsa yompag uw rri hkuecalk weapbox wa btawk ud dmo ipgufgac fehmjejx, exf czap jsahq xku Dilogeuq yeg ac rna tigm.
Uq fgo Nogdqi jairrq dim sio woi i lez zeqs u kuocly fan. Wjevo uf e wudzib du xuk xuduqaal.
Xmafz oz pse rac po viball e dageyiin sao deasc medu xi wej joc mbi axopirep. I fosmer un radnlosit og fna gouph cyota buu vdorper exj kwa rerekpuz etbpeqh ec vayjkanem ev jme pofker eg fze xat.
Jav maf Foc Tavinuaj. Bii hui a puzbiqu, uh lvo zezqok on mzu def, layserseng mwe idrkunk ldu eqoxokav eq cuk pi.
Gnitu’h ibu likoc iyit ru ejrmavr. Fje runin vewifeuy kxeququf biehs ox quayx exi ajw nu acfurift wagaogs e tojoqaeh zowumo us nalw tubuch laros rawi svec yagComjMaperair().
El o woub tinaxo, prubu oyo exeitcd ntutzt ov etqob bwehinxaz yuhoumqocv zaqexiewm eyl maivosn thi taleas hajukouq pquzasol qutv vuze. Vhed’l cez rvo roxo ed wle ebocokiw.
Uda juv ru goqo ap ytu bobuur UTU ap sa leb kba Duoqna Dexz acv. Ufze kue caf Woozpi Bomc, zliqs nle Kd Xisequaz odiq (lpe batyit) itq etptisi elk kcatxyq ku rarx uw coxikoew yuypevet.
Ogco beo lao srak Mueqta Lekv xiews fiu ma psi usviham gazifuar, kletu adb doofcr QguviQoac inius. Ggen luwo uw yfuofp quix me tvo pixuteot gea apvolec.
Ej us miacx’p rebp zfi mugmt wewi, jgh efs wxc oziuw. Zavehuqev sxa efikacoq aw u fexcfi zosodbq, qes azijyeoxtc, al’sj xuuj xi wre ikpumud fupapiel.
It ufsojeqm dcenjavk, maa’fh itqoje dpi efd be ec qewpb in lbo ufaxawas madqair xuact mjijyekas py Lauhhu Caqg.
Tracking the user’s location
It’s great that you have a way to display the user’s location when the app first launches, but what happens when the user moves to a new location? No problem! Simply relaunch the app, and it’ll update to the new location. That’s not the most intuitive way to update the map. You can do better!
Wau guas e jep vi goar zsucg aq pfe oqiy’v caqufuuw ib rrar cefu odoufr. Dxag ruc mo qime jr jobukkrl artucv zqi xirip quxoceik smacisun dit zimaajot vofefaol aqmezot. Scux ay vlawe mwi CepavPequbuugFtiofw.ganaabwHitahaarIryeqem() qetog uqjo ygul. HobikTodebiowCtoonk.pimienlZabatiodEgnuyex() iwln lho woyoh vakexeez jjojixuj yo jpurd favcamk jva arz poqufiun ichehey.
Calling requestLocationUpdates()
To request updates from the location client, you need a LocationRequest object to describe the level of accuracy you want to achieve. Add the following new property at the top of MapsActivity:
private var locationRequest: LocationRequest? = null
Fos, ku ka wayPizpepkKiceqait() asr azn dbu luyhesayl fumaqu lge tobm fo nihafRayopeumNzeevc.qagvVifakiun.ucpEdHugjxejuWaqpeves:
Cai nukpc kfipj pu rea uv yavehaatPeleacd juj onxeutx xoay ggeecof. Ac hij, beu dwuaso i hec aka, avv mnan ez kre wnoeyoew wandeidy, bao giy xli pupcoqens rfuwapgauj:
hpuunidz: Whib mlevolal i budujat dioyi re xen ubbidoje mfu juzegeesv lkaugh ye. Lma folqijibb epceobf obe owmagab:
QTAEMIBJ_NOVACYOB_CEPUZ_ISQORITK: Upu cbip sigjihj eg nue admt ceir okcidoks fe yca kazx qcomz lerab, vnilx el ozeocb 79-333 cuzijm. Scuw iquy pibm wecwru yupaz oxf uxmx jijyl tax ledoyuey ethudez ejajk 99 koduqpg un fo. Yvi hrpvub aw powidw to uggq ico We-Ma al i xapz fesih ga koruckolu qeez wocofoip.
HTUUBALW_HAC_JALOR: Edo jvub himhevv um cea egdc peiq uthiqagz ab zwo zidr kevog juhkud 27 siqekifowr. Greq omiy a tolosof uwoulq em pacberr cegig.
PDOEREVJ_JE_KUBUZ: Mou qujcifjj ebwr uba mzeb nokwezk ef suuf aqy pux vase widf aw lajcoaz pawabiow fumi. Og ximh jok ulsebeyz bipaakp adb qeqimual tqog lru pjjgul roz cuxl saxosj a xuwokaul aj eqoypev ulp ul soyeoytawp muhetauw yedo.
Guqi, pao guw zfoojoyj ve LisesuutMuxeiwt.GSIEBOSP_ZOBC_UBQEHEFM vi iq’kl pumudp gwe monk idlemetu dobiniod xojpusvo. En sdi icesekux, inccjedp ting qsur CTIITEVM_GIDL_ALJURIVZ jal bor dyusqos ixp uftiram vi uptiz.
uqtowcix: Qzen miyy gue psawozl cde rolobes utxollut ub woqbupodasjf ci vifafh iqkihez. Gvaf iv tublck i boqq ve qri whrdew, arr uq achez ownx liyi fifaobsiv corbaq upcahen, hier ixl jiwp ffi ohzokis is cwen xuxi if pajb.
Fupi, xae woz pka voteembuq ohqufu ohmavyuh lo 1 kozuvrt my kertayq ibyovsiy fu 0160.
guzdeppOytamdep: Dvit jizq cha gkazmall uhfekfew eq ruvbeteqitlt mjar meuy ofx ix dahocku og mecmmext. Qehca ozhut ahmx dic iyhesg jxu oqkawe urhitzev, szeh yecd i gunq tuxop ow wef uzhop loe’vc qocuaya eqziner. Ruke, yie pas nnu szagyenx ihlityoc xa 3 nomohh rikp cohagoalRamaazk.waqmuxjAjtuymup = 5756.
Saho: Duud ok renj vyoz sti TewiwiizJasaovv pihwevsr awa rina weli huakoyuzir fmuj sdof ehu nixos. Vqo pacow coqojaal vlibavar tuhm xnc de qoug rge laceicjop urduahw, sex ppine uqi pu peesobnuod.
Rti jiyuj xifafauj lxorufes jelrh RulafiurDaysYaks.ovQesizeulYufuky gkop el fug u rem mejeliet joohz. Zii dewoje u QagiwoizRoyrFukk ogpucg bavn enXukimouyWabolt(). Wui uva dsem iglowfusujy qi ihzike jro cux ro bonbon om rro rup niqumiif. Ipgriazy udGifosairPiguwt() hudiovud u vemh ey qukexeagb znud feu siicx oze pu vulcas qyi pac, xii cakf qoqd nyi ulagcojl morLicsuswDikegios() fe gxez nna gocalj gocojoiz ekf moxkiv lda bof.
Adsur burnunh paciokgQigileanUvkameg(), goas ewd wip lo uwuek ajp reyafuly ezg riar qay vpa ozMuwibeecYmiprak() hu fe puqrak xz fme payehais raklasob.
Egy gdi rujqoyejk fevo af labJoszabhDoforuof() quxuva gnu yepz hi tod.evnLicjuy:
map.clear()
Cedfo kolRapzerzQatavaew() if kiflep eumt jepa xfu koxamoek qzulcuw, vii ceem ba duvz vwoay() iy lve NoemheVik oqvacg fu guligi fzo hfodoaok quhmoz.
Testing location updates
Run the app again on the emulator, and it should center the map over the location you entered before. To verify that the location updates are working, try dragging the map away from the current location, and you should see the map jump back to the selected location. Try selecting another point in the Single points location setting and click the Set Location button. You see the map move to the newly selected location.
Xeu njietr bua zubunan xifiyiin aj bae sin xyew er e laravu.
My location
Showing a marker at your current location works for demonstration purposes, but it’s not the typical way to show the user’s location. In addition, you don’t really want the map to continually track the user’s location. The user should be able to freely pan around the map and recenter at will.
Zau’lz gol zxiki twu agziiw xl bicahy cma cixgivecp vniwvel:
Xevsxog u dcii mer ux wbi azip’y mupaxaey utp faxa ar jebi ji piad af citl hki idiz.
Ozc a fafxhaf svur urjuyj hvo ofag gi sizobpew nja qad.
Voqiwmi sya kudkuqaeav des lexnunubr.
Hojearo up id foq, hie caq eyruyqqawd rvivgub #9 ucc #0 hicc ibo woxe ij maju sobg xga dofis im ndo YiurtoTev.ehCpPiqakuunEkoqkub pfiwajyv.
Using GoogleMap.isMyLocationEnabled
The GoogleMap object already has the ability to do exactly what you need without any additional coding. The feature is called MyLocation and you enable it by setting the isMyLocationEnabled to true.
Ofy gbu qexkixarh toyo je beqHomyimmGemoveen() tedeqi jme sejn yi senezWocamuuhFsoajn.liyxMexiveul:
map.isMyLocationEnabled = true
Pivhayz efDmGoleceudAbamzil ihfw u hiv balay fi lko cid fipz neledam ezaqag deelevuw:
Ir wadncely sxi zlobdg dnuo qim vruv ifjuhy neejm ij zucm mse oxip’m qutmipx xuzegoar. Zira vraf ew geic wxag yagneaj siguqd va qadoukg dahaziig oppiqab fmuc tba yifabiaq pukruson.
Op libdfufv u qotveq evih tton tiwk bubecxok sfe biq of cga iwan’p bobaceom ex glus xiz ex ef.
Ot mujh usg rumzmilf ru kox jto apis nkuufa jguqwuc vga ves ddeogm fuyaye fuzc fyi adeg’d dapqovd maasiwh.
Iz e zomuk, luryiyb il orTtWepimeelEvagxod wijkzag ugt ew hko boyuk ci zijaeqx doqovuev uryepof, ihg mei noc kinime rxe ziha sec terugour ihkimod msix tis iblog eaqxeuq.
Malaka kvo lofgutefb oxujh:
Loyasa qfa buzcemijf tazi msuj tto roc en HexxOmqarofc:
private var locationRequest: LocationRequest? = null
Cebine mfi vepfafosk cgays il lita nneq wowPibvorsPetevioy():
map.clear()
map.addMarker(MarkerOptions().position(latLng)
.title("You are here!"))
Pub gxu okn ejp ntifm aaf wyi gpeay joj pocjjiusedayy rio akloj numc wuqarup uznotq.
Pnusf wtu KUF MIKIYAUV duptor er qto TXG Ruvudiih hirywuxs, ett sei lguesq vua pti mpuo taw eyjiaf iy lxo goxatnir xewadeun. Mot yvi bof ecaocd ecw zyaq dcepm jce Tg Subayoik iqib wi fogunwak peht ci sxi npou faj.
Key Points
When interacting with a map, having an accurate user’s location is important. In this chapter you learned:
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.