TLDR我想在計時器刷新層,它繪製新的KML數據(如更新鏈接/網絡鏈路)刷新/重繪的OpenLayers層(KML)網絡鏈路自動刷新
到目前爲止,我已經嘗試了動作的功能如下:功能
function RefreshKMLData(layer) {
layer.loaded = false;
layer.setVisibility(true);
layer.redraw({ force: true });
}
設定的時間間隔:
window.setInterval(RefreshKMLData, 5000, KMLLAYER);
層本身:
var KMLLAYER = new OpenLayers.Layer.Vector("MYKMLLAYER", {
projection: new OpenLayers.Projection("EPSG:4326"),
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: MYKMLURL,
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
})
});
的URL KMLLAYER與數學隨機所以它不緩存:
var MYKMLURL = var currentanchorpositionurl = 'http://' + host + '/data?_salt=' + Math.random();
我本來以爲,這將刷新層。通過將其加載到false來卸載它。真正重新加載它的能力和數學隨機不應該允許它緩存?那麼有沒有人以前做過這個或知道我如何才能使這個工作?
我的回答很老,但現在好多了。更新。 – Sphvn 2012-09-14 09:19:56