use*_*752 2 google-visualization
我们正在为我们的网站实施地理图表热图,但他们在显示英国地区方面有局限性,他们只能列出4个地区,英格兰,苏格兰,威尔士和北爱尔兰,而且不多于此.任何人都可以帮助我知道我们是否可以列出英国的所有地区,以及我们是否可以显示英国的这些地区的城市,县以及普雷斯顿等.
我们还可以传递3个以上的参数来显示鼠标悬停的更多数据.
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geochart']});
var chart;
var data;
var options;
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
data = google.visualization.arrayToDataTable([
['Region', 'Popularity', 'Total Votes'],
['England', 8, 6],
['Scotland', 8, 6],
['Wales ', 9, 7],
['Northern Ireland', 2, 5],
['United Kingdom', 2, 4]
]);
var maxV = 5; // to ensure scale is equal on both ends.
var minV = maxV*-1;
options = {
colorAxis: {colors: ['blue', 'white', 'red'], minValue: minV, maxValue: maxV},
};
chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
chart.draw(data, options);
google.visualization.events.addListener(chart, 'regionClick', selectHandler);
};
function selectHandler(e) {
var selection = e['region'];
//alert(selection);
options['resolution'] = 'provinces';
options['region'] = selection;
chart.draw(data, options);
document.getElementById('goback').style.display='block';
};
</script>
Run Code Online (Sandbox Code Playgroud)
如您所见,只有3个参数,我们可以传递额外的参数吗?或任何工具提示.
提前致谢
简短回答:不,你不能展示比英格兰,威尔士,苏格兰和北爱尔兰更具体的部门.
Google地图目前没有更具体的地图,因此您无法使用地理数据进行地图制作.
如果要显示城市,可以使用标记模式显示它们.如果您确实想要显示英国的所有ISO-3166-2区域,您唯一的选择是在标记模式下为每个区域创建坐标,然后将它们编码为圆圈,而不是阴影区域.
就显示更多工具提示而言,您可以添加工具提示列以显示您的心愿(警告:不允许回车):
function drawVisualization() {
data = new google.visualization.DataTable();
data.addColumn('string', 'Region');
data.addColumn('number', 'Popularity');
data.addColumn('number', 'Total Votes');
data.addColumn({type: 'string', role: 'tooltip'}, 'ToolTip');
data.addRows([
['England', 8, 6, 'This is England'],
['Scotland', 8, 6, 'This is Scotland'],
['Wales ', 9, 7, 'This is Wales'],
['Northern Ireland', 2, 5, 'This is Northern Ireland'],
['United Kingdom', 2, 4, 'This is the UK']
]);
var maxV = 5; // to ensure scale is equal on both ends.
var minV = maxV*-1;
options = {
colorAxis: {colors: ['blue', 'white', 'red'], minValue: minV, maxValue: maxV},
};
chart = new google.visualization.GeoChart(document.getElementById('visualization'));
chart.draw(data, options);
google.visualization.events.addListener(chart, 'regionClick', selectHandler);
}
function selectHandler(e) {
var selection = e['region'];
//alert(selection);
options['resolution'] = 'provinces';
options['region'] = selection;
chart.draw(data, options);
//document.getElementById('goback').style.display='block';
};
Run Code Online (Sandbox Code Playgroud)
将来,HTML工具提示也可能会受到支持,但即使在实验1.1版本中,它们目前也不支持地理数据.
| 归档时间: |
|
| 查看次数: |
4545 次 |
| 最近记录: |