# Change the Map Type Based on a Toggle Widget

You can dynamically change the map type based on selections in a toggle widget. For example, you can create a toggle that switches between two different types of maps.

Let’s say you want to analyze your company's performance globally and in the United States. You add a toggle that switches from a world map by country to a country map by state. And you show the world map by default if no selection is made.

![The Country and State toggle options allow you to change the map.](https://a.sfdcstatic.com/developer-website/sfdocs/analytics/media/bi_dev_guide_bindings/bi_dashboard_choropleth_map_countries_flex.png)

When you click State, the dashboard shows your results for each state.

![The map of the United States shows because the State toggle option is selected.](https://a.sfdcstatic.com/developer-website/sfdocs/analytics/media/bi_dev_guide_bindings/bi_dashboard_choropleth_map_USstates_flex.png)

The custom query (`static_1`) provides the "Country" and "State" values that appear in the toggle widget. The chart widget has a Map Type property so you can select the type of map to display. To dynamically set the map type based on a selection in the custom query (`static_1`), bind the Map Type property in the query (`State__c_1`) of the chart widget to the custom query (`static_1`). For more information about maps, see [Map Charts](https://help.salesforce.com/apex/HTViewHelpDoc?id=bi_chart_intro_map.htm).

Here’s the dashboard JSON. Focus on the `values` attribute of `static_1`, the `groups` attribute of the `State__c_1` query, and the `maps` parameter of the `chart_1` widget.

```json
{
    "label": "Choropleth Binding",
    "state": {
        "gridLayouts": [...],
        "layouts": [],
        "steps": {
            "static_1": {
                "datasets": [],
                "dimensions": [],
                "isFacet": false,
                "isGlobal": false,
                "selectMode": "single",
                "type": "staticflex",
                "useGlobal": false,
                "values": [
                    {
                        "display": "Country",
                        "grouping": "Country__c",
                        "mapType": "World Countries"
                    },
                    {
                        "display": "State",
                        "grouping": "State__c",
                        "mapType": "US States"
                    }
                ],
                "visualizationParameters": {
                    "options": {}
                }
            },
            "State__c_1": {
                "datasets": [
                    {
                        "id": "0FbB000000001uGKAQ",
                        "label": "GUS Roster",
                        "name": "Roster",
                        "url": "/services/data/v38.0/wave/datasets/0FbB000000001uGKAQ"
                    }
                ],
                "isFacet": true,
                "isGlobal": false,
                "query": {
                    "measures": [
                        [
                            "count",
                            "*"
                        ]
                    ],
                    "groups": [
                        "{{coalesce(cell(static_1.selection, 0, \\"grouping\\"), cell(static_1.result, 0, \\"grouping\\")).asString()}}"
                    ]
                },
                "type": "aggregateflex",
                "useGlobal": true,
                "visualizationParameters": {
                    "visualizationType": "hbar",
                    "options": {}
                }
            }
        },
        "widgetStyle": {...},
        "widgets": {
            "pillbox_1": {
                "parameters": {
                    "compact": false,
                    "exploreLink": false,
                    "step": "static_1"
                },
                "type": "pillbox"
            },
            "chart_1": {
                "parameters": {
                    "legend": {
                        "showHeader": true,
                        "show": true,
                        "position": "right-top",
                        "inside": false
                    },
                    "highColor": "#1674D9",
                    "lowColor": "#C5DBF7",
                    "visualizationType": "choropleth",
                    "step": "State__c_1",
                    "theme": "wave",
                    "exploreLink": true,
                    "title": {
                        "label": "",
                        "align": "center",
                        "subtitleLabel": ""
                    },
                    "trellis": {
                        "enable": false,
                        "type": "x",
                        "chartsPerLine": 4
                    },
                    "map": "{{coalesce(cell(static_1.selection, 0, \\"mapType\\"), cell(static_1.result, 0, \\"mapType\\")).asString()}}"
                },
                "type": "chart"
            }
        }
    },
    "datasets": [...]
}
```
