Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of Google map in Android

Here I'm trying to changing the color of google map into black from white but not getting a good solution. I tried it to change by using a relative layout over it but it hides that part , it doesn't change color of GoogleMap.

            <fragment xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/map"
                class="com.google.android.gms.maps.MapFragment"
                android:layout_width="match_parent"
                android:layout_height="100dp" />
like image 357
Anshul Tyagi Avatar asked Sep 05 '25 11:09

Anshul Tyagi


1 Answers

Go here: https://mapstyle.withgoogle.com/
Find your style and get json for your style value and copy.
Come to your android map project resource, click-new file, add json and paste style json value like style_map.json and your map activity's onMapReady(GoogleMap googleMap) do this:

mGoogleMap = googleMap;
MapStyleOptions mapStyleOptions = MapStyleOptions.loadRawResourceStyle(this, R.raw.style_json);
mGoogleMap.setMapStyle(mapStyleOptions);

It works for me :)

like image 133
Ravi.Sh Avatar answered Sep 08 '25 19:09

Ravi.Sh