我正在努力使美国各州的毒品死亡率大打折扣。
但是,我无法让州议会议员出现,只有阿拉斯加和夏威夷出现,而且我似乎无法弄清楚原因。
尽管如此,这还是有点新的,所以希望有人可以帮忙!

这是我的代码:

  google.load("visualization", "1", {'packages':["geochart"]});
  google.setOnLoadCallback(drawRegionsMap);
  function drawRegionsMap() {
    var data = google.visualization.arrayToDataTable([
      ['Region',   'Age-adjusted mortality rate per 100,000'],
      ['Alaska', 16.8],
      ['Alabama', -8],
      ['Arizona', 6],
      ['Arkansas', -24],
      ['California', 12],
      ['Colorado', -3],
      ['Connecticut', 3],
      ['Delaware', 28],
      ['Florida', 15],
      ['Georgia', 4],
      ['Hawaii', 35],
      ['Idaho', 12],
      ['Illinois', -12],
      ['Indiana', 6],
      ['Iowa', -3],
      ['Kansas', 12],
      ['Kentucky', 26],
      ['Louisiana', 3],
      ['Maine', 15],
      ['Maryland', 9],
      ['Massachusetts', 0],
      ['Michigan', 13],
      ['Minnesota', 5],
      ['Mississippi', 10],
      ['Missouri', 12],
      ['Montana', -1],
      ['Nebraska', -29],
      ['Nevada', 6],
      ['New Hampshire', 32],
      ['New Jersey', null],
      ['New Mexico', 33],
      ['New York', -14],
      ['North Carolina', 12],
      ['North Dakota', 18],
      ['Ohio', -20],
      ['Oklahoma', -13],
      ['Oregon', 35],
      ['Pennsylvania  ', 32],
      ['Rhode Island', -25],
      ['South Carolina', -22],
      ['South Dakota', 14],
      ['Tennessee', 8],
      ['Texas', -1],
      ['Utah', -21],
      ['Vermont', -2],
      ['Virginia', -16],
      ['Washington', 0],
      ['West Virginia', 15],
      ['Wisconsin', -5],
      ['Wyoming', 8]
    ]);

    var options = {
      region: 'US',
      colorAxis: {colors: ['#00853f', 'black', '#e31b23']},
      backgroundColor: '#81d4fa',
      datalessRegionColor: '#f8bbd0',
      defaultColor: '#f5f5f5'

    };

    var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
    chart.draw(data, options);
  };
</script>


谢谢!

最佳答案

我认为您正在寻找:resolution: 'provinces'



  google.load("visualization", "1", {'packages':["geochart"]});
  google.setOnLoadCallback(drawRegionsMap);
  function drawRegionsMap() {
    var data = google.visualization.arrayToDataTable([
      ['Region',   'Age-adjusted mortality rate per 100,000'],
      ['Alaska', 16.8],
      ['Alabama', -8],
      ['Arizona', 6],
      ['Arkansas', -24],
      ['California', 12],
      ['Colorado', -3],
      ['Connecticut', 3],
      ['Delaware', 28],
      ['Florida', 15],
      ['Georgia', 4],
      ['Hawaii', 35],
      ['Idaho', 12],
      ['Illinois', -12],
      ['Indiana', 6],
      ['Iowa', -3],
      ['Kansas', 12],
      ['Kentucky', 26],
      ['Louisiana', 3],
      ['Maine', 15],
      ['Maryland', 9],
      ['Massachusetts', 0],
      ['Michigan', 13],
      ['Minnesota', 5],
      ['Mississippi', 10],
      ['Missouri', 12],
      ['Montana', -1],
      ['Nebraska', -29],
      ['Nevada', 6],
      ['New Hampshire', 32],
      ['New Jersey', null],
      ['New Mexico', 33],
      ['New York', -14],
      ['North Carolina', 12],
      ['North Dakota', 18],
      ['Ohio', -20],
      ['Oklahoma', -13],
      ['Oregon', 35],
      ['Pennsylvania  ', 32],
      ['Rhode Island', -25],
      ['South Carolina', -22],
      ['South Dakota', 14],
      ['Tennessee', 8],
      ['Texas', -1],
      ['Utah', -21],
      ['Vermont', -2],
      ['Virginia', -16],
      ['Washington', 0],
      ['West Virginia', 15],
      ['Wisconsin', -5],
      ['Wyoming', 8]
    ]);

    var options = {
      region: 'US',
      colorAxis: {colors: ['#00853f', 'black', '#e31b23']},
      backgroundColor: '#81d4fa',
      datalessRegionColor: '#f8bbd0',
      defaultColor: '#f5f5f5',
      resolution: 'provinces'
    };

    var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
    chart.draw(data, options);
  };

<script src="https://www.google.com/jsapi"></script>
<div id="geochart-colors" style="width: 900px; height: 500px;"></div>

09-18 18:56