如何将动态kml添加到谷歌地球?
我们正在尝试向 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()
函数。我们能够在谷歌地球上第一次获取kml。如果我们第二次点击,那么我们就可以了谷歌地球上没有获取kml。但是test.kml
文件正在更新新值。那么,我们如何从谷歌地球中删除kml?
如有帮助,将不胜感激。
We are trying to add dynamic kml to google earth.But we are failing in one situation.
CODE:
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);
}
}
When we click on button we are calling loadkmlGE()
function.We are able to get the kml first time on google earth.If we click second time then we are not getting kml on google earth.But test.kml
file is updating new values.So, how we can remove the kml from google earth?
Help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
fetchKml 我相信使用浏览器来获取文件。除非另有说明,它通常会缓存文件。
您可以安排服务器使用 HTTP 标头告诉浏览器它无法缓存该文件。取决于您的服务器如何设置。
...或者只是安排每次更改的网址。
或类似的。服务器很可能会忽略伪造的参数。但由于 URL 已更改,浏览器将不会有缓存版本。
fetchKml I beleive uses the browser to fetch the file. It will generally cache the file unless told otherwise.
You could arrange for the server to tell the browser it cant cache the file - using HTTP headers. depends on your server how to set that up.
... or just arrange the url to change each time.
or similar. The server will likly ignore the bogus param. But as the URL has changed the browser wont have a cached version.