将数据源从融合表更改为excel文件(链接)

时间:2015-06-18 07:22:14

标签: javascript excel google-maps google-fusion-tables alasql

出于安全考虑,我必须将所有数据从融合表移植到excel文件,并仍保留融合表功能,该功能用作谷歌地图的来源。现在我面临的问题是我遇到了alasql。我想用这个来完成我的任务。但我无法找到任何有关alasql的文档示例,其中excel和google地图仅使用javascript。

有人能指出一个恰当的例子,我可以参考或使用excel和gmaps的alasql上的任何文档。下面的代码是我必须从融合表移植到链接给出的excel文件。

google.load('visualization', '1', {'packages':['table']});
function initialize() {  
 var map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(55.7200,12.5700),
zoom: 2,
minZoom: 1,
maxZoom: 4,
mapTypeControl: false,
streetViewControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
  });

var layer = new google.maps.FusionTablesLayer({
query: {
  select: 'Address',
  from: '1234324235435435' // fusion table id here
},
suppressInfoWindows: true
});
layer.setMap(map);

google.maps.event.addListener(layer, 'click', function(e) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'header1:');
data.addColumn('string', e.value1);
data.addRows([
  ['header2', e.value2],
  ['header3', e.value3],
  ['header4', e.value4],
  ['header5', e.value5],
  ['header6', e.value6],
  ['header7', e.value7],
  ['header8', e.value8],
  ['header9', e.value9],
  ['header10', e.value10],
       ]);

 var chart = new google.visualization.Table(document.getElementById('chart'));
var options = {
  'title': e.row['header'].value + ' ',
};
 chart.draw(data, options);
 });
}

function changeData(Sitecode) {
  var whereClause = "";
  if(Sitecode) {
 whereClause =  " WHERE 'Sitecode' = '" + Sitecode + "'"+"order by StartTime DESC limit 3";
 }
   var queryText = encodeURIComponent("SELECT 'Sitecode', 'IncidentID', 'IncidentReport', 'Resolved', 'StartTime' FROM 12345678" + whereClause);
  var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq='  + queryText);

   query.send(getData);
 }

 function getData(response) {
 var table = new    google.visualization.Table(document.getElementById('visualization'));
  table.draw(response.getDataTable());
 }

 function UpgradeData(Sitecode) {
 var whereClause = "";
  if(Sitecode) {
    whereClause =  " WHERE 'Sitecode' = '" + Sitecode + "'";
  }
  var queryText = encodeURIComponent("SELECT 'Sitecode', 'curver' as Current_Version, 'upon' as Upgraded_On, 'upnext' as Next_Upgrade, 'upnotes' as Upgrade_Notes FROM 123456789" + whereClause);
  var query = new   google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq='  + queryText);

   query.send(getdata);
}

function getdata(response) {
    var table = new           google.visualization.Table(document.getElementById('visualization1'));
   table.draw(response.getDataTable());
}

0 个答案:

没有答案