Change Google map theme – Android

google-map-theme
 

Change Google Map theme of your Android project.

In this article, I will show you how to change the theme of google map. What we are going to do is create a basic Google map project and change the theme of the map.

There are six themes available for google map. The standard style, Silver, Retro, Dark, Night and Aubergine. We can also change the density of Roads, Landmarks, and Labels. So let’s see how to do it.

google-map-theme

Google map integration – Android

At first, create a new google map project and do the necessary setup.  Now we have to create the map tyle. We can create map style with Google Map Style Generator.

map-style

After creating the style click Finish. The generator will generate the style in JSON format. We have to copy the JSON and paste into our app.

json-map-styleGo to Android Studio and define a raw resource in /res/raw/map_style.json. Right click on res, go to New and click Android Resource Directory. Select the Resource type as raw and click Ok.

raw-resource-android
Right click on raw directory. Go to New and select File. Now enter the file name as map_style.json or anything.json. It will create an empty .json file. Here in this file, you have to paste the JSON of your Google map style.

 google-map-android

Now go to MapsActivity.java or whatever the name of your map activity file name is, and paste the below line inside onMapReady.

This returns a boolean value. Returns false if the style parsing fails for some reason.

That’s all. You have successfully changed the theme of your Google map. Now run your app and you will see the new style of your google map. If you have any doubt or facing any problem don’t hesitate to comment below in the comment section.

 

You May Also Like

1 Comment

  1. This site is awesome. Nice tutorials on android. I was really searching for this tutorial. I am a beginner. Just started android programming 🙂 Thank you, sir.

Leave a Reply

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