Return to Video

Coding with MarkerOptions

  • 0:00 - 0:02
    So here's a mapping app
    that I've already created.
  • 0:02 - 0:05
    This one is identical to all the others
    that you've been using throughout this
  • 0:05 - 0:06
    course.
  • 0:06 - 0:10
    It has a single view and
    there's a map fragment on that view.
  • 0:10 - 0:14
    The Gradle file is set up for
    the play-services libraries.
  • 0:14 - 0:18
    And the manifest file is set up
    in the usual way with OpenGL,
  • 0:18 - 0:22
    with the services libraries, with the
    API key, and with the permissions that I
  • 0:22 - 0:28
    want to use, internet access network
    state and write external storage.
  • 0:28 - 0:30
    And of course on my
    Google Developers Console,
  • 0:30 - 0:33
    as I showed you earlier on,
    I've configured this API for
  • 0:33 - 0:36
    access through that API key and
    the API key is here.
  • 0:36 - 0:38
    Now let's take a look
    at the main activity.
  • 0:38 - 0:42
    So in my main activity class I've just
    created a number of local variables
  • 0:42 - 0:47
    of marker options type and I just named
    them after the various rinks, renton,
  • 0:47 - 0:49
    kirkland, everett, lynnwood,
    montlake, kent and showare.
  • 0:49 - 0:53
    I've also created a camera
    position that I called Seattle,
  • 0:53 - 0:56
    which is just the default
    camera position that I'm using
  • 0:56 - 0:58
    when the application actually launches.
  • 0:58 - 1:00
    Then, in my uncreate function,
  • 1:00 - 1:04
    I called the marker options in the way
    that I had demonstrated on the slide.
  • 1:04 - 1:07
    So, for example, Renton is new
    marker options with the latitude and
  • 1:07 - 1:10
    longitude of Renton and
    the title Renton.
  • 1:10 - 1:13
    I was able to get the latitudes and
    longitudes for each of the rinks
  • 1:13 - 1:16
    using the technique that I showed
    earlier on just using Google Maps,
  • 1:16 - 1:19
    dropping a pin and reading
    the latitude and longitude from them.
  • 1:19 - 1:22
    So I've set up all of my marker
    options for all of my rinks.
  • 1:22 - 1:25
    And then in my onMapReady function, so
  • 1:25 - 1:29
    remember the onMapReady callback
    gets called when the map is ready,
  • 1:30 - 1:33
    because I've implemented onMapReady
    callback in my activity.
  • 1:33 - 1:38
    So when the onMapReady gets called,
    I simply add all the markers to my maps
  • 1:38 - 1:43
    so, m map dot add marker Renton and
    map dot add marker Kirkland, etcetera.
  • 1:43 - 1:46
    I add them all and
    then I call fly to Seattle.
  • 1:46 - 1:49
    And the flyTo function is very similar
    to the one you saw in the previous
  • 1:49 - 1:53
    demo except this time I'm just moving
    the camera, I'm not animating it.
  • 1:53 - 1:55
    So then I'm just going to
    fly to Seattle and
  • 1:55 - 1:57
    I'm just going to jump
    into that location.
  • 1:57 - 2:00
    I haven't put any flyTo
    to the particular rinks.
  • 2:00 - 2:03
    The only time flyTo has been
    called in this application
  • 2:03 - 2:06
    is right at the beginning,
    when I say flyTo(SEATTLE).
  • 2:06 - 2:08
    And the only time that the flyTo
    function's called is, of course,
  • 2:08 - 2:10
    in the on mapReady
    when I flyTo(SEATTLE).
  • 2:10 - 2:13
    So that would just give me a default
    view, looking at Seattle in
  • 2:13 - 2:16
    the location where we could see
    all of the rinks on the same map.
  • 2:16 - 2:19
    So, I had moved the camera to
    the appropriate location to allow me to
  • 2:19 - 2:23
    do that, and that was the camera
    that was defined as Seattle.
  • 2:23 - 2:26
    As you can see here,
    with the latitude/longitude, zoom of 10,
  • 2:26 - 2:29
    bearing of 0, so I'm looking straight
    down, and a tilt of 45 degrees.
  • 2:29 - 2:32
    That was pretty simple, right?
  • 2:32 - 2:34
    And in the next step here, you're
    actually going to build a custom marker,
  • 2:34 - 2:37
    so you're not going to use
    the default marker pen.
  • 2:37 - 2:40
    You can create your own marker,
    for example, a hockey player.
  • 2:40 - 2:43
    But before we get to that, let's have a
    little quiz about using markers on maps.
Tytuł:
Coding with MarkerOptions
Opis:

03-08 Coding with MarkerOptions

more » « less
Video Language:
English
Team:
Udacity
Projekt:
ud876-4 - Google Play Services - Maps
Duration:
02:44

English subtitles

Revisions Compare revisions