1

I have a database with thousands of (latitude,longitude) points stored in it. Those points are plotted into a map using a tile server. Such tile server first computes, for each tile, the points that fall inside the tile, and then draws every point(after coordinates conversion). My Javascript looks as follows:

var overlayMaps = [{
  getTileUrl: function(coord, zoom) {
    return "tileserver.php?x="+coord.x+"&y="+coord.y+"&z="+zoom+"&g=1";
  },

  tileSize: new google.maps.Size(256, 256),
  isPng: true,
  opacity: 1.0
}];

var overlayMap = new google.maps.ImageMapType(overlayMaps[0]);
map.overlayMapTypes.setAt(0,overlayMap);

Now, I am dynamically adding new records to the database every 5 seconds, and I want the respective tiles to be updated (re-computed and re-displayed) every 5 seconds.

How could I trigger my tile server to re-compute tiles of the viewport every 5 seconds ?

Added: The tiles are updated every 5 seconds without problems, but the main problem now is re-displaying them on the map...

Thanks in advance...

1
  • Thanks! I tried to use the current time instead of a random number (as the r you stated ), and it worked !
    – D T
    Oct 18, 2011 at 15:14

1 Answer 1

1

Tiles are images,you can't possibly know which one of these may change.Also,you can't refresh single tiles but entire viewport.All you can do,serving your tiles dynamically,each time viewport changes or not tile images not cached,so they always change.For this,you can put a time flag or random number into your tile url code like this.

"tileserver.php?x="+coord.x+"&y="+coord.y+"&z="+zoom+"&g=1&r=" + Math.random(); 

Best Regards

2
  • Although having such parameter is a good option, tiles will be blinking for a moment when reloaded. those who want to avoid this please visit the following link: groups.google.com/forum/#!topic/google-maps-js-api-v3/…
    – D T
    Oct 19, 2011 at 8:22
  • Changing opacity until tile becomes invisible,then releasing tile,then reloading it looks better idea.I will try this method as well.Thank you for sharing David
    – Myra
    Oct 19, 2011 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.