Rutas del estilo.pdf

download Rutas del estilo.pdf

of 24

Transcript of Rutas del estilo.pdf

  • 8/10/2019 Rutas del estilo.pdf

    1/24

    Rutas del estilo: https://www.google.es/maps/@40.440847,-3.626841,17z

    1. Downloading Google Play Services

    Google made new Maps V2 API as a part of Google Play Services SDK. So before we

    start developing maps we need to download google play services from SDK manger. o!

    can open SDK manager eit"er from #clipse or from android sd$ folder.

    %pen Eclipse Windows Android SDK Managerand c"ec$ w"et"er yo! "ave

    already downloaded Google Play Services or not !nder Extrassection. If not select play

    services and install t"e pac$age.

    https://www.google.es/maps/@40.440847,-3.626841,17zhttps://www.google.es/maps/@40.440847,-3.626841,17z
  • 8/10/2019 Rutas del estilo.pdf

    2/24

    2. Importing Google Play Services into Eclipse

    After downloading play services we need to import it to #clipse w"ic" will be !sed as a

    library for o!r maps pro&ect.

    1. In #clipse goto FileImport Android Existing Android ode Into Wor!space

    ". 'lic$ on (rowse and select Google Play Services pro&ect from yo!r android sd$ folder.

    o! can locate play services library pro&ect from

    android#sd!#windows$extras$google$google%play%services$li&pro'ect$google#play#

    services%li&

    (. Importantly w"ile importing c"ec$ opy pro'ects into wor!space option as s"own in

    t"e below image.

  • 8/10/2019 Rutas del estilo.pdf

    3/24

    3. Getting the Google Maps API ey

    1. Same as in maps v) we need to generate S*A+) fingerprint !sing &ava !eytool . %pen

    yo!r terminal and e,ec!te t"e following command to generate S*A+) fingerprint.

    )n Windows

    keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore"-alias androiddebu

  • 8/10/2019 Rutas del estilo.pdf

    4/24

    )n *in+x or Mac )S

    keytool -list -v -keystore !.androiddebug.keystore -alias androiddebugkey -storeas

    In t"e o!tp!t yo! can see S*A ) finger print.

    ". -ow open Google API 'onsole

    (. Select Serviceson left side and t!rn on Google Maps Android API v"

    ,. -ow select API Accesson left side and on t"e rig"t side clic$ on reate new Android

    !ey-

    https://code.google.com/apis/console/https://code.google.com/apis/console/
  • 8/10/2019 Rutas del estilo.pdf

    5/24

    .. It will pop!p a window as$ing t"e S*A) and pac$age name. #nter yo!r S /A 1 and

    yo!r android pro'ect pac!age name separated by semicolon 0 and clic$ on create.

  • 8/10/2019 Rutas del estilo.pdf

    6/24

    I "ave given li$e below

    #E$&$E'$(($&)$*#$E+$'*$,$)F$*F$#*$)+$+,$E$F$+($$F#$/0in1o.android2ive.google3a

    And note down t"e API $ey w"ic" re!ired later in o!r pro&ect.

  • 8/10/2019 Rutas del estilo.pdf

    7/24

    !. "reating new Pro#ect

    After completing re!ired config!ration/ It0s time to start o!r pro&ect.

    1. In #clipse create a new pro&ect by going to File ew Android Application

    Pro'ect and fill re!ired details. I $ept my pro&ect name as Google Maps 2" and

    pac$age name asin3o4android5ive4in3o

    ". -ow we need to !se Google Play Services pro&ect as a library to !se pro&ect. So rig5t

    clic!on pro&ect and select properties. In t"e properties window on left side

    select Android. %n t"e rig"t yo! can see aAddb!tton !nder library section. 'lic$ it and

    select google play servicespro&ect w"ic" we imported previo!sly.

  • 8/10/2019 Rutas del estilo.pdf

    8/24

  • 8/10/2019 Rutas del estilo.pdf

    9/24

  • 8/10/2019 Rutas del estilo.pdf

    10/24

    (. Add t"e Map Key in t"e manifest file. %pen AndroidMani3est4xml file and add t"e

    following code before tag. 1eplace t"e android6val+e wit" yo!r map $ey w"ic" yo! got

    from google console.

    45-- 6oolge 7as PI 8ey --9

    43eta-data

    android$na3e:";o3.google.android.3as.v,.PIaSy#?7lkOv(s@-7ABO)/CksdaD(E@Lgo"9

    ,. Google maps needs following permissions and feat!res.

  • 8/10/2019 Rutas del estilo.pdf

    11/24

  • 8/10/2019 Rutas del estilo.pdf

    12/24

    4uses-er3issionandroid$na3e:";o3.google.android.roviders.gs1.er3ission.RE

  • 8/10/2019 Rutas del estilo.pdf

    13/24

    android$value:"I>aSy#?7lkOv(s@-7ABO)/CksdaD(E@Lgo"9

    4ali;ation9

    43ani1est9

    .. -ew google maps are implemented !sing MapFragments w"ic" is a s!b class

    of Fragments class. %pen yo!r main activity layo!t file activity%main4xml file and

    add following code. I !sed8elative*ayo+t as a parent element. o! can remove it and

    !se Map5ragment directly.

    a&ti(it)*mai!.%ml

    4GD3lversion:"'."en;oding:"ut1-+"G9

    4RelativeLayoutD3lns$android:"http://s&hemas.a!d"oid.&om/ap'/"es/a!d"oid"

    android$layout

  • 8/10/2019 Rutas del estilo.pdf

    14/24

    MOverride

    rote;tedvoidonHreateQ#undle savedInstan;eState

    suer.onHreateQsavedInstan;eState0

    setHontentieCQR.layout.a;tivitye7aQ0

    ;at;2QED;etion e

    e.rintSta;kra;eQ0

    TT

    T 1un;tion to load 3a. I1 3a is not ;reated it Cill ;reate it 1or you

    T T

    rivatevoidinitili>e7aQ

    i1Qgoogle7a :: null

    google7a : QQ7aFrag3ent getFrag3ent7anagerQ.1indFrag3ent#yIdQ

    R.id.3a.get7aQ0

    ;2e;k i1 3a is ;reated su;;ess1ully or not

    i1Qgoogle7a :: null

    oast.3akeeDtQgetli;ationHonteDtQ

    "Sorry5 unable to ;reate 3as" oast.LE6N

  • 8/10/2019 Rutas del estilo.pdf

    15/24

    MOverride

    rote;tedvoidonResu3eQ

    suer.onResu3eQ0

    initili>e7aQ0

    1!n yo!r pro&ect and congrat!lations if yo! see a map displaying on yo!r device.

  • 8/10/2019 Rutas del estilo.pdf

    16/24

  • 8/10/2019 Rutas del estilo.pdf

    17/24

    Placing a Marer

    o! can place a mar$er on t"e map by !sing following code.

    latitude and longitude

    doublelatitude : 0

    doublelongitude : 0

    ;reate 3arker

    7arkerOtions 3arker : neC7arkerOtionsQ.ositionQneC LatLngQlatitude longitude.t

    adding 3arker

    google7a.add7arkerQ3arker0

  • 8/10/2019 Rutas del estilo.pdf

    18/24

  • 8/10/2019 Rutas del estilo.pdf

    19/24

    "hanging Marer "olor

    (y defa!lt map mar$er color will be 1#D. Google maps provides some set of predefined

    colored icons for t"e mar$er.

    ROSE ;olor i;on

    3arker.i;onQ#it3aes;ritorFa;tory.de1ault7arkerQ#it3aes;ritorFa;tory.NUE

  • 8/10/2019 Rutas del estilo.pdf

    20/24

    Apart from maps native mar$er icons/ yo! can !se own image to s"ow as a mar$er. o! can

    load t"e icon from any $ind of s!pported so!rces.

    3 ro mA ss et ;S tr in g a ss et a me < 8oading from assets folder

    3rom=itmap ;=i tmap image< 8oading bitmap image

    3romFi le ;String pat5< 8oading from file

    3rom8eso+rce ;int reso+rceId< 8oading from drawable reso!rce

    (elow I loaded a c!stom mar$er icon from drawa&lefolder

    latitude and longitude

    doublelatitude : '*.&+A((0

    doublelongitude : *+.(+//*'0

    ;reate 3arker

    7arkerOtions 3arker : neC7arkerOtionsQ.ositionQneC LatLngQlatitude longitude.t

    H2anging 3arker i;on

    3arker.i;onQ#it3aes;ritorFa;tory.1ro3Resour;eQR.draCable.3y

  • 8/10/2019 Rutas del estilo.pdf

    21/24

    5ollowing are en"ancements and feat!res t"at google maps provides. o! can !tili9e t"ese

    feat!res w"ic" s!ites to yo!r re!irements.

    "hanging Map &ype

    Google provides : $inds of map types ormal/ /y&rid/ Satelliteand 7errain. o! can

    toggle to any $ind of map !sing googleMap4setMap7ype;< met"od.

    google7a.set7ayeQ6oogle7a.7P

  • 8/10/2019 Rutas del estilo.pdf

    22/24

  • 8/10/2019 Rutas del estilo.pdf

    23/24

    Showing "$rrent %ocation

    o! can s"ow !ser0s c!rrent location on t"e map by

    calling setMy*ocationEna&led;< . Pass tr!e ; false to enable or disable t"is feat!re

    google7a.set7yLo;ationEnabledQtrue0 1alse to disable

    'ooming ($ttons

    o! can call set>oomontrolsEna&led;< f!nction to get rid of t"ose 9ooming

    controls on t"e map. (y disabling t"ese b!ttons map 9ooming f!nctionality still wor$ by

    pinc"ing gest!re.

    google7a.getUiSettingsQ.set?oo3HontrolsEnabledQ1alse0 true to enable

    'ooming )$nctionality

    o! can disable 9ooming gest!re f!nctionality by

    calling set>oomGest+resEna&led;