Select platform: [Android](https://developers.google.com/maps/documentation/android-sdk/dds-boundaries/choropleth-map.md.txt "View this page for the Android platform docs.") [iOS](https://developers.google.com/maps/documentation/ios-sdk/dds-boundaries/choropleth-map.md.txt "View this page for the iOS platform docs.") [JavaScript](https://developers.google.com/maps/documentation/javascript/dds-boundaries/choropleth-map.md.txt "View this page for the JavaScript platform docs.")

<br />

A choropleth map is a type of thematic map in which administrative areas are
colored or shaded according to a data value. You can use a style factory
function to style a map based on data where each administrative area is
associated with a range of numeric values. The following example map shows a
choropleth map for the states of the United States.

In this example, the data consists of the place ID of the state. The style
factory function conditionally colors each state based on a hashed value of the
place ID for the state.

![A screenshot showing a choropleth map of the US states.](https://developers.google.com/static/maps/documentation/android-sdk/images/dds-choropleth.png)

> [!NOTE]
> **Note:** Typically, you would define a table of the color for each state, and then lookup the color for each state based on the state's place ID.

1. If you haven't already done so, follow the steps in
   [Get Started](https://developers.google.com/maps/documentation/android/dds-boundaries/start)
   to create a new map ID and map style. Be sure to enable the
   **Administrative Area Level 1** feature layer.

2. Get a reference to the Administrative Area Level 1 feature layer when the
   map initializes. For the United States, these administrative levels
   correspond to the individual states.

   ### Java


   ```java
   private FeatureLayer areaLevel1Layer;

   @Override
   public void onMapReady(GoogleMap map) {
     areaLevel1Layer = map.getFeatureLayer(new FeatureLayerOptions.Builder()
       .featureType(FeatureType.ADMINISTRATIVE_AREA_LEVEL_1)
       .build());

     // Apply style factory function to ADMINISTRATIVE_AREA_LEVEL_1 layer.
     styleAreaLevel1Layer();
   }
   ```

   <br />

   ### Kotlin


   ```java
   private var areaLevel1Layer: FeatureLayer? = null

   override fun onMapReady(googleMap: GoogleMap) {
     // Get the ADMINISTRATIVE_AREA_LEVEL_1 feature layer.
     areaLevel1Layer = googleMap.getFeatureLayer(FeatureLayerOptions.Builder()
       .featureType(FeatureType.ADMINISTRATIVE_AREA_LEVEL_1)
       .build())

     // Apply style factory function to ADMINISTRATIVE_AREA_LEVEL_1 layer.
     styleAreaLevel1Layer()
   }
   ```

   <br />

3. Create a style factory function and apply it to the
   Administrative Area Level 1 feature layer. The following example applies the
   function to the polygon representing each state of the United States.

   ### Java


   ```java
   private void styleAreaLevel1Layer() {
     FeatureLayer.StyleFactory styleFactory = (Feature feature) -> {
       if (feature instanceof PlaceFeature) {
         PlaceFeature placeFeature = (PlaceFeature) feature;

         // Return a hueColor in the range [-299,299]. If the value is
         // negative, add 300 to make the value positive.
         int hueColor = placeFeature.getPlaceId().hashCode() % 300;
         if (hueColor < 0) {
           hueColor += 300;
         }

         return new FeatureStyle.Builder()
           // Set the fill color for the state based on the hashed hue color.
           .fillColor(Color.HSVToColor(150, new float[] {hueColor, 1, 1}))
           .build();
       }
       return null;
     };

     // Apply the style factory function to the feature layer.
     areaLevel1Layer.setFeatureStyle(styleFactory);
   }
   ```

   <br />

   ### Kotlin


   ```java
   private fun styleAreaLevel1Layer() {
     val styleFactory = FeatureLayer.StyleFactory { feature: Feature ->
         if (feature is PlaceFeature) {
             val placeFeature: PlaceFeature = feature as PlaceFeature

             // Return a hueColor in the range [-299,299]. If the value is
             // negative, add 300 to make the value positive.
             var hueColor: Int = placeFeature.getPlaceId().hashCode() % 300
             if (hueColor < 0) {
                 hueColor += 300
             }
             return@StyleFactory FeatureStyle.Builder()
             // Set the fill color for the state based on the hashed hue color.
               .fillColor(Color.HSVToColor(150, floatArrayOf(hueColor.toFloat(), 1f, 1f)))
               .build()
         }
         return@StyleFactory null
     }

     // Apply the style factory function to the feature layer.
     areaLevel1Layer?.setFeatureStyle(styleFactory)
   }
   ```

   <br />