0

下面的代码用于使 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);
}

4

1 回答 1

0

此加密 ID 无效:1IagEEylcnbuPygCES70ipnvb9q0C5OgmGPNyx9o1

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

于 2013-01-23T04:55:18.970 回答