如何在 Android 中更改 Google 地图的颜色

Ans*_*agi 3 android google-maps android-maps-v2

在这里,我试图将谷歌地图的颜色从白色改为黑色,但没有得到很好的解决方案。我尝试通过在它上面使用相对布局来改变它,但它隐藏了那个部分,它不会改变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" />
Run Code Online (Sandbox Code Playgroud)

小智 5

去这里:https : //mapstyle.withgoogle.com/
找到你的风格并为你的风格值获取 json 并复制。
来到你的 android 地图项目资源,点击新文件,添加 json 并粘贴样式 json 值,如 style_map.json 和你的地图活动onMapReady(GoogleMap googleMap)这样做:

mGoogleMap = googleMap;
MapStyleOptions mapStyleOptions = MapStyleOptions.loadRawResourceStyle(this, R.raw.style_json);
mGoogleMap.setMapStyle(mapStyleOptions);
Run Code Online (Sandbox Code Playgroud)

这个对我有用 :)