使用google.visualization.Query时,Fusion表失败(测试1成功,但类似的test2失败)

时间:2013-01-23 00:28:36

标签: google-maps-api-3 google-fusion-tables

以下代码用于将google-fusion-table与markercluster一起使用。 (参考:http://www.cs.gsu.edu/~ashrestha2/vis/prjmap2.html 非常荣幸作者 但是,当我尝试按照上面的链接中的示例时,我在测试1中成功但在测试2中失败。测试1使用具有两列的融合表,测试2使用具有三列的融合表。我不知道为什么我失败了,因为我只为测试2添加了一列。

google.load('visualization', '1.0', {"callback":initialize});   
//var tableid = '1_6G1c1l7glLHRuOU7uvH8oONbObDf_cOtZS21Rc', atlcenter = new google.maps.LatLng(33.755711,-84.388372);    //test1_success
var tableid = '1IagEEylcnbuPygCES70ipnvb9q0C5OgmGPNyx9o1', atlcenter = new google.maps.LatLng(33.755711,-84.388372); //test2_fail

var mapMain, markers, dataTable = null, mc = null;

function initialize() {     
    mapMain = new google.maps.Map(document.getElementById('map-canvas'), {
        center: atlcenter,
        zoom: 5,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    mc = new MarkerClusterer(mapMain);
    queryMap("select * from "+tableid);
}

function queryMap(queryText){
    mc.clearMarkers(); markers=[];
    var tmp = 'http://www.google.com/fusiontables/gvizdata?tq='+encodeURIComponent(queryText);
    var query = new google.visualization.Query(tmp); 
    query.send(handleQueryResponse); 
}

function handleQueryResponse(response){
    dataTable = response.getDataTable();
    alert(response.isError()); 
    for(var i=0; i< dataTable.getNumberOfRows();i++){           
        var hrefval = dataTable.getValue(i,0).toString();
        var arr = dataTable.getValue(i,1).toString().split(" ");            
        var latlng = new google.maps.LatLng(arr[0], arr[1]);        
        var marker = new google.maps.Marker({
            position: latlng,
            map:mapMain
        });     
        markers.push(marker);   
    }
    mc.addMarkers(markers);
}

1 个答案:

答案 0 :(得分:0)

此加密ID无效: 1IagEEylcnbuPygCES70ipnvb9q0C5OgmGPNyx9o1

https://www.google.com/fusiontables/DataSource?docid=1IagEEylcnbuPygCES70ipnvb9q0C5OgmGPNyx9o1