2011-12-14 172 views

回答

3

有可能使用谷歌API图表显示只有某个国家。 实现它的方法是在选项变量中设置区域,并在绘制地图时使用选项变量。

var options = {}; 
options['region'] = 'AU'; 
... 
geomap.draw(data, options); 

退房API文档中提供的示例:http://code.google.com/apis/chart/interactive/docs/gallery/geomap.html#markersexample

+0

哦!我怎么能错过这个,一直在寻找大量的例子......谢谢Steffen! – 2011-12-14 16:04:57

0

我曾尝试谷歌图表代码与我的Web应用程序。但这不适合我。 包装['Map']正在工作 使用['Geomap']包我的网页上没有显示任何东西。
和使用包['map'],我猫只显示1个国家图表。有什么我失踪了吗?

<script type='text/javascript'> 
      google.charts.load('current', {'packages': ['geomap']}); 
      google.charts.setOnLoadCallback(drawMap); 
      function drawMap() 
        var data = google.visualization.arrayToDataTable([ 
          ['City', 'Popularity'], 
          ['New York', 200], 
          ['Boston', 300], 
          ['Miami', 400], 
          ['Chicago', 500], 
          ['Los Angeles', 600], 
          ['Houston', 700] 
        ]); 
        var options = {}; 
      options['region'] = 'US'; 
      options['colors'] = [0xFF8747, 0xFFB581, 0xc06000]; //orange colors 
      options['dataMode'] = 'markers'; 
      var container = document.getElementById('map_canvas'); 
      var geomap = new google.visualization.GeoMap(container); 
      geomap.draw(data, options); 
    }; 
</script>  
<div id="map_canvas" style="width: 900px; height: 500px;"></div> 
相关问题