[MUSIC PLAYING]
Markers-- they're much more useful than just
for showing a location on a map.
Actually, they can be used to visually convey
information about a location.
I'm Ankur Kotwal, and together we're
going to look at ways to visualize locations on a map.
Let's say a user is searching for a well-rated restaurant.
They'd fire up your app and see that there's
a bunch of restaurants in their vicinity.
But it's not always easy to tell which ones are worth visiting.
To see the ratings for each place,
they may end up having to tap each one first and see
the rating.
Marker selection and animations can be a great way
to show this information.
In this example, markers that lack color rate poorly.
And the vibrant, colorful markers
are the highly rated ones.
There's also animated steam on some of these markers,
helping to highlight the best rated restaurants.
To achieve this animation, we're changing the marker icon
by calling setIcon periodically.
To desaturate the marker icons, we're
also using a ColorMatrix ColorFilter
from the Android framework.
First, we set up the ColorFilter based on the rating scale.
And then we apply the filter to the marker image.
Now, markers are great for showing points on a map,
but sometimes you can just have too many.
In this case, we have too many well-rated restaurants
around us.
It's a nice problem to have, but it's not helping
our user choose a restaurant.
And in such situations, you need to display many markers,
but still keep the view comprehensible.
So we're going to look at two ways to overcome these issues.
The first is through the use of marker clustering.
As the zoom levels of the map change,
you can aggregate markers, making for a much more
digestible view.
Now, a zoomed out view shows us how many restaurants
are in the surrounding areas.
You might be looking at this effect
and wondering that well, it looks like a lot of work.
Well, let me put you at ease.
It's a four-step process.
Step one, add the library to your gradle config.
Step two, add the GetLocation override
to your main data class.
Step three, instantiate the ClusterManager
and register it for a couple of map listeners.
And finally, step four, replace your marker management code
with calls to the ClusterManager.
It will manage adding and removing the markers for you.
Seriously, that's it, four steps.
You can optionally customize it further
by providing custom aggregate markers too.
Let's look at the second method to show marker aggregation.
I reckon it looks really cool.
Heat maps.
Here, we're replacing a count of markers with a heat map
to show the concentration of these markers.
How cool does that look?
Achieving this effect is also just four steps.
One, add the library.
Two, instantiate a HeatMapTileProvider.
Three, pass it your LatLngs.
And four, use it to create a map overlay.
That's it.
You can optionally customize this further
by specifying the gradient and the radius of the heat map,
too.
So just remember, information overload
is a common problem with mobile apps.
Location apps in particular suffer from poor user
experiences when dealing with lots and lots of information.
Markers, clustering, and heat maps
offer beautiful visualizations, enabling
you to build amazing maps.
The Android Maps utils library provides
easy to use implementations for marker clustering, heat maps,
and even more.
So be sure to check it out right here.
I'm Ankur Kotwal, and I look forward
to seeing your amazing maps.
[MUSIC PLAYING]