Maps Shortcuts: Android Maps Utility Library


CHRISTOPHER BROADFOOT: Hello. Welcome to this week’s Google
Maps Developer Shortcuts. I’m coming to you from the
Sydney studio, where we have new couches and I have a little
more facial hair after Google I/O. Speaking of I/O, if
you haven’t already watched my talk, I strongly
suggest you do. It’s called When Android Meets
Maps, and it gives you a run down of the Google Maps Android
API and some of the cool things you can
do with it. So speaking of cool things, I
talked a little bit about this utility library at I/O, and
today, I’ve extended it a little bit more. So it’s called the
android-maps-utils library. It has a poly util, a spherical
util, and as of today, a Bubble Icon Factory. So let’s talk about poly
util just very quickly. At the moment, it has
one function. It’s decode. It will take an encoded
poly line or polygon, which is a string. You might get this from the
Google Directions API, and it will give you back a list of
latitude and longitude points. Spherical util is great if you
need to do things like compute distances between points, areas,
headings between two points, or simply interpolate. Perhaps you want to
animate a marker between Sydney and France. You can cycle through that
third value to get a nice smooth line between
Sydney and France. There’s many more functions. These are just a
small sampling. So let’s talk about Bubble
Icon Factory. Essentially, it just
lets you generate marker images like this. These sort of look like info
windows, but each marker is always showing. So this is great for showing
small snippets of information such as house prices,
as you can see here. It’s really simple. You just create a new Bubble
Icon Factory, and you call Make Icon. And you pass out a string, and
that string will be shown within that marker icon. You get back a Bitmap, which
you can pass through to the Bitmap descriptor factory. And you just add that
to your marker through the icon option. Of course, you can use setIcon
to change that marker later. So you can change
the color it it. Here you can see that
we’ve got white markers and green markers. So you can just call Set Style
on the factory and just say that you want a green style. You can change these styles at
any time, so you can, for example, set a whole bunch of
styles on the factory or maybe create separate factories
for two different types of markers. It’s really up to you. So the other neat thing
about this is that you can rotate markers. Here you can see that we’ve
got markers that are pointing downwards. So this is great for a small
snippet of information once again, like house prices, where
you don’t really want to interfere with the
map too much. So we’ve gone a little bit
crazy with colors here. You might want to stick to one
or two different colors. But the library ships with a lot
of different styles that might suit your application. It’s just the orange, red,
purple, blue and green. So as I said, you can set the
rotation of the marker. You can rotate the marker
itself or just the content within it. So with these markers where
the text is just pointing down, we just set the content
rotation to 90 degrees. Now, you could have markers
that are sticking outwards like a little tag as well. That’s all quite possible. You can also change the content
view completely. For instance, if you’d like to
display an image within that little bubble, you
can do that too. You just call Set
Content View. Perhaps you want to pass an
image view down to that. And instead of calling Make Icon
with a string, you just call Make Icon, and you
get back that Bitmap. So a little tip– these can be run off the main
thread, off the UI thread, so you could go and generate all of
these in parallel or in the background, perhaps
in an async task. And once it’s generated back on
the UI thread, go on, put that marker onto the map. So go and check it out. It’s on It’s distributed as an Android
library project, much like Action Bar Sherlock or
something like that. You’re probably familiar
with it. Actually, in fact, you’re
already familiar with it if you’re using the Maps API,
because the Google Play services client is distributed
as a library project. So just go ahead and drop that
into your project, and you can start using this poly util,
spherical util, and the Bubble Icon Factory. Well, I hope that helps, and
I’ll see you around next time. Thank you.

Tags: , , , , , , ,

18 thoughts on “Maps Shortcuts: Android Maps Utility Library”

  1. Noel Higgins says:

    Wow no comments yet?

  2. Francisco Javier Nuñez says:

    Wow Google Maps has a lot of new features this Google IO 2013, thanks and I hope to use them in my new project.

  3. happy15sheng says:

    nice neat introduction

  4. wassollderscheiss33 says:

    Thanks! I like that! 🙂

  5. wassollderscheiss33 says:

    Took me about 12 hours now trying to integrate your library into my application (using Android Studio) but it just won't work. Always getting the "NoClassDefFoundError:". I tried referencing your library in every way I could imagine; obviously I am still doing something wrong. Too bad you didn't tell what to do 🙁 I will have to create my own bubble Icons now…

  6. jeffrey Manalang says:

    How to integrate your library ?? need help

  7. Chris Broadfoot says:

    Check the website:

  8. Chris Broadfoot says:

    Check the website: – see the Gradle instructions

  9. ttttkk2 says:

    hi, when i tried to import the library, there is a red cross I can't get rid you know how?

  10. Võ Hoàng Tú says:

    hi! i import 'Android- Maps-utility/library' on eclipse, it Erorro!

  11. Võ Hoàng Tú says:

    link website unable in to

  12. Aris Miliotis says:

    Is this still current?
    I am trying to use it in Android Studio 0.8.2 and I am getting a warning that BubbleIconFactory is deprecated, and the makeIcon() method does not exist 🙁
    I am quite the noob so I am not sure I added it correctly to my project, but at least import; gives no error…
    I need to create markers on the fly from other conditions in my code, any thoughts?
    Thank you.

  13. Ovidiu Latcu says:

    +1 for the funny intro 😀

  14. patelismail patel says:

    thanks a lot dude …..

  15. Ramiro Madriaga says:

    How you get the private final static String LINE = "rvumEis{y[}[email protected]………………..

  16. Ramiro Madriaga says:

    Hi, i have the build.gradle
    Error(64,0) No such property: sonatypeUsername for class: org.gradle.api.internal.project.DefaultProject_Decorated problem..

  17. Ignacio Garat says:

    Hi is it possible to show icon and title at the same time using this API? Thank you very much.

  18. nag sumanth says:

    Can some one help me to add a marker to map which always stays at the center of the map(even when the map is being scrolled)

Leave a Reply

Your email address will not be published. Required fields are marked *