当地区设置为加拿大时,我需要在地理图上隐藏美国:
谷歌。负载("可视化","1",{"包":[' geochart ']});google.setOnLoadCallback (drawVisualization);
函数drawVisualization() {var data = new google.visualization.DataTable();
data.addColumn('string', 'Country');
data.addColumn('number', 'Value');
data.addColumn({type:'string', role:'tooltip'});var ivalue = new Array();
data.addRows([[{v:'CA-BC',f:'CA-BC'},0,'Test']]);
var options = {
backgroundColor: {fill:'#FFFFFF',stroke:'#FFFFFF' ,strokeWidth:0 },
colorAxis: {minValue: 0, maxValue: 0, colors: ['#0000ff',]},
legend: 'none',
backgroundColor: {fill:'#FFFFFF',stroke:'#FFFFFF' ,strokeWidth:0 },
datalessRegionColor: '#f5f5f5',
displayMode: 'markers',
enableRegionInteractivity: 'true',
resolution: 'provinces',
region:'CA',
keepAspectRatio: true,
width:700,
height:500,
tooltip: {textStyle: {color: '#444444'}, trigger:'focus'}
};
var chart = new google.visualization.GeoChart(document.getElementById('visualization'));
chart.draw(data, options);
}
http://jsfiddle.net/jk171505/VJtBR/使用API选项,您无法真正做到这一点。您可以使用高级CSS选择器来隐藏SVG形状。
添加这个CSS,它将隐藏US形状:
#visualization path:nth-child(237), #visualization path:nth-child(236) {
display:none;
}
http://jsfiddle.net/cmoreira/mMadX 我已经建立了一个页面,其中有一些关于如何使用这个和其他CSS技术与谷歌地理图API的信息。如果有帮助,这里是链接:http://cmoreira.net/interactive-world-maps-demo/advanced-customization/