how to correctly reload fusion tables layer?

元气小坏坏 提交于 2019-12-10 12:05:24

问题


i have a fusion table that changes very often.

And i have a javascript code that allows to visualize location information from database.

But how can i reload map without reloading whole page.

This is my code:

function initialize() {

map = new google.maps.Map(document.getElementById('map_canvas'), {
  center: new google.maps.LatLng(60,30),
  zoom: 9,
  mapTypeId: google.maps.MapTypeId.ROADMAP
});


layer = new google.maps.FusionTablesLayer({
  query: {
    select: 'location',
    from: '3415835'
  }
});

layer.setMap(map); 
}

I've already tried this:

function initialize() {

//var chicago = new google.maps.LatLng(60, 40);


map = new google.maps.Map(document.getElementById('map_canvas'), {
  center: new google.maps.LatLng(60,30),
  zoom: 9,
  mapTypeId: google.maps.MapTypeId.ROADMAP
});


layer = new google.maps.FusionTablesLayer({
  query: {
    select: 'location',
    from: '3415835'
  }
});



layer.setMap(map);   
refreshMap();

 }              

function refreshMap(){

 layer.setOptions({
   query: {
       select: 'location',
    from: '3415835'
    }
}); 


setTimeout('refreshMap()',5000);    
}

this one didn't worked.


回答1:


Have you tried throwing in a layer.setMap(null); in the mix, and then resetting it?



来源:https://stackoverflow.com/questions/9994764/how-to-correctly-reload-fusion-tables-layer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!