To create your map, call GoogleMap.setMapStyle () , passing in a MapStyleOptions object containing style declarations in JSON format. You can load JSON from a raw resource or line in the mapReady () function ... so after declaring it json, calling your map ready function will almost look like
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; try { // Customise the styling of the base map using a JSON object defined // in a raw resource file. boolean success = mMap.setMapStyle( MapStyleOptions.loadRawResourceStyle( this, R.raw.style_json)); if (!success) { Log.e("MapsActivityRaw", "Style parsing failed."); } } catch (Resources.NotFoundException e) { Log.e("MapsActivityRaw", "Can't find style.", e); } }
Define the source resource in / res / raw / style _json.json containing the JSON style declaration for night mode
You can get json from the following link https://mapstyle.withgoogle.com/
source share