Why a layer was incorrectly reloaded?

2019-02-20 00:42发布

问题:

I've got a problem that was discribed over there:

how to correctly reload fusion tables layer?

Briefly: i have a fusion table that changes very often.

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

Thanks everyone, i've managed to solve this thing. This is the code that works as it should:

var map;
var layer;
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);   
   refreshMap();

}              

function refreshMap(){

  layer.setOptions({
  query: {
  select: 'location',
  from: '3415835',
   where: "location not equal to" + (-1 * Math.floor(Math.random() * 10000000)).toString()
     }

  }); 


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

At first t thought that my code is wrong. But after testing i discovered that layer is

being reloaded incorrectly: when new point is added i can see it on one zoom level but on

another level it dissapears. i dnon't know what's causing this: browser is cashing map or

script is wrong or smth else. Can someone help me?