0

当用户更改缩放级别时,我想重新加载 Fusion Tables 图层。可以看出,我尝试过但无法使其工作。

var map;
var layerl0;
    function initialize() {
    map=new google.maps.Map(document.getElementById('map_canvas'),{
        center: new google.maps.LatLng(MyLat,MyLng),
            zoom:4,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        });
        layerl0 = new google.maps.FusionTablesLayer({
                    query: {
                        select: "'ColumnHeader'",
                        from: 'MyEncryptedId'
                },
                map: map
        });
        /* refresh after zooming */
        google.maps.event.addListener(map, 'zoom_changed', function() {
                layerl0.refresh();
    });
    }
google.maps.event.addDomListener(window, 'load', initialize);
4

3 回答 3

2

FusionTablesLayer上没有 .refresh 方法

重新运行查询或销毁并重新创建 FusionTablesLayer

于 2012-06-28T13:31:05.213 回答
2

这是解决方案。(我在这里找到了)

每 30 秒刷新一次图层:

var map;
var layerl0;
    function initialize() {
    map=new google.maps.Map(document.getElementById('map_canvas'),{
        center: new google.maps.LatLng(MyLat,MyLng),
        zoom: 4,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    layerl0 = new google.maps.FusionTablesLayer({
        query: {
            select: "'ColumnHeader'",
            from: 'MyEncryptedId'
        },
    });
    layerl0.setMap(map);
    refreshMap();
}
function refreshMap(){
    layerl0.setOptions({
        query: {
        select: "'ColumnHeader'",
        from: 'MyEncryptedId',
            where: "location not equal to" + (-1 * Math.floor(Math.random() * 10000000)).toString()
        }
    }); 
    setTimeout('refreshMap()',30000);
}
google.maps.event.addDomListener(window, 'load', initialize);

感谢您回答@Rebecca 和@geocodezip!

于 2012-06-29T11:26:23.380 回答
0

此示例代码旨在在用户更改缩放时交换不同的 Fusion Table Layer。也许它会有所帮助: https ://developers.google.com/fusiontables/docs/samples/change_query_per_zoom

-丽贝卡

于 2012-06-28T18:17:26.503 回答