Select platform: [Android](https://developers.google.com/maps/documentation/android-sdk/hiding-features.md.txt "View this page for the Android platform docs.") [iOS](https://developers.google.com/maps/documentation/ios-sdk/hiding-features.md.txt "View this page for the iOS platform docs.") [JavaScript](https://developers.google.com/maps/documentation/javascript/json-styling-overview.md.txt "View this page for the JavaScript platform docs.")

<br />

As well as changing the style of features on the map, you can also hide them
entirely. This example shows you how to hide business points of interest (POIs)
and public transit icons on your map.

Styling works only on the `normal` map type. Styling does not affect
[indoor maps](https://developers.google.com/maps/documentation/android-sdk/map.md.txt#indoor), so using styling to hide features does not prevent
indoor floor plans from appearing on the map.

## Pass a JSON style object to your map

To style your map, call [`GoogleMap.setMapStyle()`](https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.md.txt#setMapStyle(com.google.android.gms.maps.model.MapStyleOptions)) passing a
[`MapStyleOptions`](https://developers.google.com/android/reference/com/google/android/gms/maps/model/MapStyleOptions.md.txt) object that contains your style
declarations in JSON format. You can load the JSON from a raw resource or a
string, as shown in the following examples:

### Raw resource

The following code sample assumes your project contains a raw resource named
`style_json`:

```
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.example.styledmap;

import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MapStyleOptions;

/** A styled map using JSON styles from a raw resource. */
public class MapsActivityRaw extends AppCompatActivity implements OnMapReadyCallback {

    private static final String TAG = MapsActivityRaw.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Retrieve the content view that renders the map.
        setContentView(R.layout.activity_maps_raw);

        // Get the SupportMapFragment and register for the callback
        // when the map is ready for use.
        SupportMapFragment mapFragment =
                (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    /**
     * Manipulates the map when it's available. The API invokes this callback when the map is ready
     * for use.
     */
    @Override
    public void onMapReady(GoogleMap googleMap) {

        try {
            // Customise the styling of the base map using a JSON object defined
            // in a raw resource file.
            boolean success =
                    googleMap.setMapStyle(
                            MapStyleOptions.loadRawResourceStyle(this, R.raw.style_json));

            if (!success) {
                Log.e(TAG, "Style parsing failed.");
            }
        } catch (Resources.NotFoundException e) {
            Log.e(TAG, "Can't find style. Error: ", e);
        }
        // Position the map's camera near Sydney, Australia.
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(-34, 151)));
    }
}
```

Define a raw resource in `/res/raw/style_json.json`, containing
the following JSON style declaration to hide business points of interest
(POIs):
Show/Hide the JSON.

```
[
  {
    "featureType": "poi.business",
    "elementType": "all",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  }
]
```

The following style declaration hides business points of
interest (POIs) and public transit icons:
Show/Hide the JSON.

```
[
  {
    "featureType": "poi.business",
    "elementType": "all",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "transit",
    "elementType": "labels.icon",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  }
]
```

The layout (`activity_maps.xml`) looks like this:
Show/Hide the layout file.

```
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.mapstyles.MapsActivityRaw"
    map:cameraZoom="13" />
```

### String resource

The following code sample assumes your project contains a string resource
named `style_json`:

```
package com.example.styledmap;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MapStyleOptions;

/**
 * A styled map using JSON styles from a string resource.
 */
public class MapsActivityString extends AppCompatActivity
        implements OnMapReadyCallback {

    private static final String TAG = MapsActivityString.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Retrieve the content view that renders the map.
        setContentView(R.layout.activity_maps_string);

        // Get the SupportMapFragment and register for the callback
        // when the map is ready for use.
        SupportMapFragment mapFragment =
                (SupportMapFragment) getSupportFragmentManager()
                        .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    /**
     * Manipulates the map when it's available.
     * The API invokes this callback when the map is ready for use.
     */
    @Override
    public void onMapReady(GoogleMap googleMap) {

        // Customise the styling of the base map using a JSON object defined
        // in a string resource file. First create a MapStyleOptions object
        // from the JSON styles string, then pass this to the setMapStyle
        // method of the GoogleMap object.
        boolean success = googleMap.setMapStyle(new MapStyleOptions(getResources()
                .getString(R.string.style_json)));

        if (!success) {
            Log.e(TAG, "Style parsing failed.");
        }
        // Position the map's camera near Sydney, Australia.
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(-34, 151)));
    }
}
```

Define a string resource in `/res/values/style_strings.xml`,
containing the following JSON style declaration to hide business points of
interest (POIs). In this file you need to use a backslash to escape the
quotation marks:
Show/Hide the JSON.

```
<resources>
  <string name="style_json">
  [
    {
      \"featureType\": \"poi.business\",
      \"elementType\": \"all\",
      \"stylers\": [
        {
          \"visibility\": \"off\"
        }
      ]
    }
  ]
  </string>
</resources>
```

The following style declaration hides business points of
interest (POIs) and public transit icons:
Show/Hide the JSON.

```
<resources>
  <string name="style_json">
  [
    {
      \"featureType\": \"poi.business\",
      \"elementType\": \"all\",
      \"stylers\": [
        {
          \"visibility\": \"off\"
        }
      ]
    },
    {
      \"featureType\": \"transit\",
      \"elementType\": \"labels.icon\",
      \"stylers\": [
        {
          \"visibility\": \"off\"
        }
      ]
    }
  ]
  </string>
</resources>
```

The layout (`activity_maps.xml`) looks like this:
Show/Hide the layout file.

```
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.mapstyles.MapsActivityString"
    map:cameraZoom="13" />
```

## JSON style declarations

Styled maps use two concepts to apply colors and other style changes to a
map:

- **Selectors** specify the geographic components that you can style on the map. These include roads, parks, bodies of water, and more, as well as their labels. The selectors include *features* and *elements* , specified as `featureType` and `elementType` properties.
- **Stylers** are color and visibility properties that you can apply to map elements. They define the displayed color through a combination of hue, color, and lightness/gamma values.

See the [style reference](https://developers.google.com/maps/documentation/android-sdk/style-reference.md.txt) for a detailed description of the
JSON styling options.

## Maps Platform Styling Wizard

[](https://mapstyle.withgoogle.com)[](https://mapstyle.withgoogle.com)[](https://mapstyle.withgoogle.com)[![](https://developers.google.com/static/maps/documentation/images/retro.png)](https://mapstyle.withgoogle.com/) [![](https://developers.google.com/static/maps/documentation/images/aubergine.png)](https://mapstyle.withgoogle.com/) [![](https://developers.google.com/maps/documentation/images/silver.png?size=140x140)](https://mapstyle.withgoogle.com/) [![](https://developers.google.com/static/maps/documentation/images/dark.png)](https://mapstyle.withgoogle.com/) [![](https://developers.google.com/static/maps/documentation/images/standard.png)](https://mapstyle.withgoogle.com/) [![](https://developers.google.com/static/maps/documentation/images/night.png)](https://mapstyle.withgoogle.com/) [Create
custom styles for the Google Maps Platform APIs](https://mapstyle.withgoogle.com)

Use the [Maps Platform Styling Wizard](https://mapstyle.withgoogle.com) as a quick way to generate
a JSON styling object. The Maps SDK for Android supports the same style
declarations as the Maps JavaScript API.

## Full code samples

The [ApiDemos repository](https://github.com/googlemaps-samples/android-samples/blob/main/ApiDemos) on GitHub includes
samples that demonstrate the use of styling.