Google Maps API v3 - KML Layer Changes

I am using google.maps.KmlLayer ('http://mywebsite.com/my.kml') to set objects from a KML file. It works, but when I change kml and try to update the website ... I still have the same state as before ... without my changes. When I change the file name to my2.kml - it works ... Are Google caching my kml? What do I need to do to update changes with the same kml file name?

+7
source share
2 answers

Google servers actually store KML cache data. Since Google servers process your KML, not your browser, clearing the cache will not help. This is why changing the file name works. To prevent caching, add cache bits to your KML URL with which you are creating the KML layer, such as a random number or current timestamp. http://mywebsite.com/my.kml?rev=323626252346 , where the rev value changes with every page refresh. You can also write Javascript so that you can click a button that updates the URL of the KML Layer object, eliminating the need to refresh the page.

+10
source

Yes, google servers cache KML data. So avoid this caching, change the kml url to

"http://www.kmlsource.com/foo.kml?dummy=" + (new Date()).getTime(); 

This will always create a new website and the caching problem will be resolved.

+5
source

All Articles