代码之家  ›  专栏  ›  技术社区  ›  Tom

为什么从google文档中绘制地图需要50秒

  •  0
  • Tom  · 技术社区  · 15 年前

    为什么从谷歌文档中绘制地图需要50秒,我只有两列40行: 列是CITY,NAME。有些城市是重复的。根据firebug的说法,网络连接只需要2-3秒。所有的城市都在一个国家,我可以优化这个吗?

    我的代码是:

      google.load('visualization', '1',
              {'packages': ['table', 'map']});
          google.setOnLoadCallback(initialize);
    
          function initialize() {
            // The URL here is the URL of the spreadsheet.
            // This is where the data is.
            var query = new google.visualization.Query(
                'http://spreadsheets.google.com/tq?key=xx');        
            query.send(draw);
          }
    
          function draw(response) {
            if (response.isError()) {
              alert('Error in query');
            }
    
    
    
    
            var geoView = new google.visualization.DataView(response.getDataTable());
            //geoView.setColumns([0, 1,2]);
    
            var table =
                new google.visualization.Table(document.getElementById('table_div'));
            table.draw(response.getDataTable(), {showRowNumber: false});
    
            var map =
                new google.visualization.Map(document.getElementById('map_div'));
            map.draw(geoView, {showTip: true});
    
    1 回复  |  直到 15 年前
        1
  •  0
  •   Emil    15 年前

    你的代码很简单,我看不到任何能减慢它速度的东西。在我的应用程序中,我使用了一些可视化效果,包括表视图和地图,显示了77行。大约需要30秒。可能只是你的连接或域。