Customize the styling of the base map using a JSON object defined in a raw resource file.
private fun setMapStyle(map: GoogleMap) {
try {
val success = map.setMapStyle(
MapStyleOptions.loadRawResourceStyle(
this,
R.raw.map_style
)
)
if (!success) {
Log.e(mTAG, "Style parsing failed.")
}
} catch (e: Resources.NotFoundException) {
Log.e(mTAG, "Can't find style. Error: ", e)
}
}
Shorter version:
val style = MapStyleOptions.loadRawResourceStyle(
this,
R.raw.default_map_style
)
mMap.setMapStyle(style)
mMap.mapType = GoogleMap.MAP_TYPE_NORMAL