2020-07-18

kmlファイルのキャッシュを削除する方法

Googleの仕様でキャッシュが強力に残ってしまい、ブラウザのキャッシュ削除だけではどうにも消す事が出来ない場合、 kmlを読み込むメタタグの後ろに適当に毎回変わる引数をつけてあげれば回避できる様子。


  1. var timeTmp=new Date();
  2. var folderPathLength = location.href.lastIndexOf("/");
  3. var folderPath = location.href.substring(0,folderPathLength);
  4. var myURL = folderPath + "/mymap.kml"+ "?d=" + timeTmp.getMinutes() + timeTmp.getSeconds();

参考:
GoogleMapsでKMLファイルを読み込む際キャッシュが残る問題の回避方法


以上