[英]how to add dynamic kml to google earth?
我们正在尝试向Google Earth添加动态kml。但是在一种情况下我们失败了。
码:
var currentKmlObject = null;
function loadkmlGE(){
if (currentKmlObject != null) {
ge.getFeatures().removeChild(currentKmlObject);
currentKmlObject = null;
}
var url = 'test.kml';
google.earth.fetchKml(ge, url, finished);
}
function finished(kmlObject) {
if (kmlObject) {
currentKmlObject = kmlObject;
ge.getFeatures().appendChild(currentKmlObject);
} else {
setTimeout(function() {
alert('Bad or null KML.');
}, 0);
}
}
当我们点击按钮时,我们调用loadkmlGE()
函数。我们能够在Google Earth上第一次获取kml。如果我们第二次单击,那么我们就不在Google Earth上获取kml。但是test.kml
文件正在更新新值.so,我们如何从Google Earth中删除kml?
帮助将不胜感激。
fetchKml我beleive使用浏览器来获取文件。 除非另有说明,否则它将通常缓存文件。
您可以安排服务器告诉浏览器它无法缓存文件 - 使用HTTP标头。 取决于您的服务器如何设置。
...或者只是安排每次更改的网址。
var url = 'test.kml?rnd='+Math.random();
或类似的。 服务器可能会忽略伪造的参数。 但是,由于URL已更改,浏览器将不会有缓存版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.