我正在学习使用谷歌Geochart工具,我想重新创建一个这样的地图:
我的代码是:
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['States', 'Number of killings'],
['California', 292],
['Texas', 143],
['Washington', 120]
]);
var options = {
region: 'US'
};
var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));
chart.draw(data, options);
}
我能看到地图,但我看不到状态划分和我使用的颜色http://jsfiddle.net,我确信这是一个非常基本的错误,但我找不到。
答案 0 :(得分:0)
添加{resolution: provinces}
:
工作代码段:
google.setOnLoadCallback(drawRegionsMap);
google.load('visualization', '1', {
packages: ['map']
});
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['States', 'Number of killings'],
['California', 292],
['Texas', 143],
['Washington', 120]
]);
var options = {
region: 'US',
resolution: 'provinces'
};
var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));
chart.draw(data, options);
}
<script src="https://www.google.com/jsapi"></script>
<div>
<div id="regions_div" style="width: 500px; height: 400px;"></div>
</div>