# Choropleth Overlay

This is an example overlay that draws choropleths over a map using canvas. Adjust the more interesting props using the controls below.


```js
const ChoroplethOverlay = require('./choropleth-overlay');

<MapGL {...viewport} mapStyle={mapStyle}>
    <ChoroplethOverlay
      features={this.state.features}
      colorDomain={[0, 100]}
      colorRange={['hsl(0.8, 1, 0.8)', 'hsl(0, 1, 1)']}
      valueAccessor={f => f.properties.value}
      globalOpacity={0.8}
    />
</MapGL>
```

## Props

#### features
An array of GeoJSON features.

```js
const features = [
  {
    type: 'Feature',
    geometry: {
      type: 'Polygon',
      coordinates: [...]
    }
  },
  ...
];
```

#### valueAccessor

Use the `valueAccessor` prop to provide the value in a custom property. It's called with each feature as the first argument. Here's the default `valueAccessor`.

```js
function valueAccessor(feature) {
  return feature.get('properties').get('value');
}
```

#### colorDomain

An array of values to be passed to [d3.scaleLinear.domain](https://github.com/d3/d3-scale#linear-scales).
It reflects the range of input values of all features.


#### colorRange

An array of strings to be passed to [d3.scaleLinear.range](https://github.com/d3/d3-scale#linear-scales).
It reflects the range of output colors for all features.


#### globalOpacity

Opacity of the dots when drawing into the canvas. Default `1`.
