5

我们有一个场景,我们希望在 Google Geochart 上绘制大量(可能多达 100 或 200 个)标记。在绘制标记时,图表似乎在一段时间内绘制这些标记,我们认为这对我们的用户来说花费了太长时间。我们希望它们立即或至少更快地显示。

我似乎没有找到任何文件来表明这是可配置的,那么有没有办法加快速度呢?

我在下面包含了示例代码来复制可以在可视化操场上运行的示例代码。

    function drawVisualization() {
  var data = google.visualization.arrayToDataTable([
    ['City', 'Count'],
['London',245],
['Manchester',58],
['Birmingham',54],
['Stoke-on-trent',30],
['Leicester',26],
['Liverpool',25],
['Nottingham',19],
['Preston',18],
['Glasgow',15],
['Leeds',14],
['West Bromwich',13],
['Sheffield',11],
['Cardiff',8],
['Wigan',8],
['Wolverhampton',8],
['Bolton',7],
['Bradford',7],
['Edinburgh',7],
['Telford',7],
['Warrington',7],
['Romford',6],
['Stockport',6],
['Swansea',6],
['Burnley',5],
['Coventry',5],
['Dagenham',5],
['Ipswich',5],
['Milton Keynes',5],
['Newcastle Upon Tyne',5],
['Northampton',5],
['Birkenhead',4],
['Blackburn',4],
['Burton-on-trent',4],
['Croydon',4],
['Durham',4],
['Reading',4],
['Rotherham',4],
['Saint Helens',4],
['Stafford',4],
['Stevenage',4],
['Sunderland',4],
['Accrington',3],
['Ashford',3],
['Bangor',3],
['Barrow',3],
['Blackpool',3],
['Bristol',3],
['Bury',3],
['Cambridge',3],
['Chesterfield',3],
['Chorley',3],
['Dundee',3],
['Heywood',3],
['Ilford',3],
['Lancaster',3],
['Luton',3],
['Mansfield',3],
['Newport',3],
['Oldbury',3],
['Oldham',3],
['Plymouth',3],
['Sale',3],
['Slough',3],
['Southend-on-sea',3],
['Stratford-upon-avon',3],
['Aylesbury',2],
['Bedford',2],
['Brighton',2],
['Caerphilly',2],
['Cannock',2],
['Canterbury',2],
['Carshalton',2],
['Chatham',2],
['Chelmsford',2],
['Cheltenham',2],
['Chester',2],
['Corby',2],
['Crawley',2],
['Crumlin',2],
['Cwmbran',2],
['Exeter',2],
['Folkestone',2],
['Gravesend',2],
['Guildford',2],
['Halesowen',2],
['Harrow',2],
['Huddersfield',2],
['Isleworth',2],
['Lichfield',2],
['Lincoln',2],
['Mitcham',2],
['Oxford',2],
['Peterborough',2],
['Rawtenstall',2],
['Rochdale',2],
['Scunthorpe',2],
['Solihull',2],
['South Shields',2]

  ]);

  var geochart = new google.visualization.GeoChart(
      document.getElementById('visualization'));
  geochart.draw(data, {width: 556, height: 347, region: 'GB', displayMode: 'markers', legend:'none'});
}
4

2 回答 2

4

这是因为 Google 将您的位置转换为经度/纬度的速度非常缓慢;您应该一次性解决它们并直接使用它们(标记模式格式)。

于 2012-10-02T10:22:42.447 回答
3

这是一个关于如何使用 lat/long 并放置信息工具提示的示例:

http://jsfiddle.net/cmoreira/njB6m/

 data.addColumn('number', 'Lat');                                
 data.addColumn('number', 'Long');
 data.addColumn('string','tooltip');
 data.addColumn('number','Example');                                 

data.addRows([[41.151636,-8.569336,'Portugal',{v:0,f:'test PT'}]]);
data.addRows([[ 39.059575,-98.789062,'USA',{v:1,f:'test US'}]]);
于 2012-10-05T10:14:50.133 回答