Android Google Map Styles Like Uber With Examples

Have you ever noticed how Uber and other few popular location-based applications have a different style of Google Maps? Some times it looks even better than the default Google Map Style. Today we’ll see how to implement Google map styles in our Android Application.

Overview

We have discussed and implemented Google Maps in quite a few tutorials until now. Here’s a list of them:

Android Studio provides a default template for Google Maps. Let’s use that.

As covered in the previous tutorials, you need to add the API key to use Google Maps from the Google Cloud Console.

To set Map styles we simply do the following on the instance of Google Map.

Project Structure

android-google-maps-style-project-309x450

 

Android Google Maps Style Project

The map styles are present in the raw folder JSON files. You can customize them or explore the various map styles from the web.

Code

The code for the activity_maps.xml is given below:

SupportMapFragment is used to showcase the map in the layout of our activity.

The code for the MapsActivity.java class is given below:

Once the map is ready, the onMapReady gets triggered. Inside this, we set a dummy location marker. The setMapStyle is used to toggle through the various map styles stored in the array.

Let’s look at the output of the above application in action:

Android Google Maps Styled Output

Android Google Maps Styled Output

That brings an end to this quick tutorial on styling Google Maps in Android.

You can download the full source code from below or browse through it from our Github Repository.

By admin

Leave a Reply

%d bloggers like this: