4

I made an app that shows Google maps with the Traffic Layer. The problem I have is that it always shows the traffic layer in the cache, so it is completely useless. I need the cache for other stuff.

How can I prevent the Traffic Layer from using the cache without completely disabling it from the app?

Umur Kontacı
  • 35,403
  • 8
  • 73
  • 96
Luis A. Florit
  • 2,169
  • 1
  • 33
  • 58

1 Answers1

4

As i already answered here, there seem to be no legal way to update traffic layer, even maps.google.com page don't autoupdate it. But i've found dirty hack that makes thing work - updating tile images manually:

function reloadTiles() {
    var tiles = $("#map-canvas").find("img");
    for (var i = 0; i < tiles.length; i++) {
        var src = $(tiles[i]).attr("src");
        if (/googleapis.com\/vt\?pb=/.test(src)) {              
            var new_src = src.split("&ts")[0] + '&ts=' + (new Date()).getTime();
            $(tiles[i]).attr("src", new_src);                                                   
        }               
    }
} 
Community
  • 1
  • 1
Sergio
  • 6,900
  • 5
  • 31
  • 55