Home / Blog / Android Development: Styling Google Maps

Android Development: Styling Google Maps

Google has a reputation for making development easier and efficient for developers who use their tools and APIs with detailed documentations and well taught free courses. I recently tried implementing styling and reducing how much information is shown on a map via android. My initial approach was to figure out how to remove certain elements from the maps api instance I was using at runtime. This approach would have been quite messy, but also mainly because, I was still figuring out the API. I did some searching and found out that Google actually makes the whole process easier. To implement styling and control how much information is shown on a map;

1. Go to https://mapstyle.withgoogle.com. This is a simple and straightforward site that enables you to create a map style by adjusting density of the main features (labels, landmarks, roads). There are also predefined themes you can select from. The advanced option allows you to further define properties and styling for several elements such as visibility, colour, weight, saturation, etc.

Once you have finished customising your map, click finish and copy the JSON generated style.

2. In your android project, create a new raw file in your raw resource folder (res/raw). You could name it whatever you want, say maps_style.json. 

3. In your code, go to your onMapReady() function, which is, the function that initialises and loads your map. Add the following lines of code;

The entire function would look like this;

Replace maps_style with the name of your raw JSON style for your map. Rebuild, run your project and watch your maps come to life with the new style.

Image credit: maps-apis.googleblog.com




24,978 total views, 21 views today

Check Also

Fix Issue With Logs Not Showing Up in Android Studio 2.3 Update

Google recently updated android studio to version 2.3, and just like most updates in the ...

Leave a Reply

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