GoogleChart GeoChart - French region map?

2019-06-06 08:39发布

问题:

I want to display a map of a region of France with GeoChart.

https://developers.google.com/chart/interactive/docs/gallery/geochart#regions-mode-format

The ISO 3166 code mentionned in the previous link is, for example, FR-U for the Provence-Alpes-Côte d'Azur region.

https://en.wikipedia.org/wiki/Provence-Alpes-C%C3%B4te_d'Azur

Here's my options:

var options = {
    region: 'FR-U',
    displayMode: 'markers',
    colorAxis: {colors: ['green', 'blue']}
};

However this does not works. I'm getting the following error message: Requested map does not exist.. This is not due to my code since if I put FR instead of FR-U it works fine.

Is the map simply not existing?

回答1:

the link you reference is the Data Format for a Regions chart

and is separate from the Configuration Options

the option for region accepts the following...

'world' - A geochart of the entire world.

A continent or a sub-continent, specified by its 3-digit code, e.g., '011' for Western Africa.

A country, specified by its ISO 3166-1 alpha-2 code, e.g., 'AU' for Australia.

A state in the United States, specified by its ISO 3166-2:US code, e.g., 'US-AL' for Alabama. Note that the resolution option must be set to either 'provinces' or 'metros'.

see following example for France...

note the resolution

google.charts.load('current', {
  callback: function () {
    new google.visualization.GeoChart(document.getElementById('chart_div')).draw(
      google.visualization.arrayToDataTable([
        ['Destination', 'Popularity'],
        ['FR-A', 100],
        ['FR-B', 105],
        ['FR-C', 110],
        ['FR-P', 115],
        ['FR-D', 120],
        ['FR-E', 125],
        ['FR-F', 130],
        ['FR-G', 140],
        ['FR-H', 150],
        ['FR-I', 160],
        ['FR-Q', 175],
        ['FR-J', 190],
        ['FR-K', 215],
        ['FR-L', 235],
        ['FR-M', 255],
        ['FR-N', 280],
        ['FR-O', 305],
        ['FR-R', 335],
        ['FR-S', 365],
        ['FR-T', 400],
        ['FR-U', 440],
        ['FR-V', 480],
      ]),
      {
        colorAxis: {colors: ['green', 'blue']},
        displayMode: 'regions',
        region: 'FR',
        resolution: 'provinces'
      }
    );
  },
  packages:['geochart']
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>