我正在加载ESRI地图和KML图层一切正常!
问题: KML数据更改后(经常更改),我无法在地图中显示新的更改。我需要有力地 每次都清除浏览器缓存。我尝试刷新图层没有用。
我的代码
// Create a new KmlLayer object.
ESRI.ArcGIS.Client.Toolkit.DataSources.KmlLayer theKmlLayer = new ESRI.ArcGIS.Client.Toolkit.DataSources.KmlLayer();
// Set the KmlLayer's ID.
theKmlLayer.ID = "SampleData";
// Set the Url of the KmlLayer. Note the Url takes a Uri object!
theKmlLayer.Url = new Uri("localhost/KML/east.kml");//Here is the New KML Data
// Need to use a ProxyUrl on the KmlLayer since the service is not hosted locally or on a local network.
theKmlLayer.ProxyUrl = "http://serverapps.esri.com/SilverlightDemos/ProxyPage/proxy.ashx";
// Add the KmlLayer to the Map. An automaic refresh of the Map and Legend Controls will occur.
Map1.Layers.Add(theKmlLayer);
我尝试了 theKmlLayer.Refresh();
我是否需要通过代码清除浏览器缓存,还是可以加载新数据?
答案 0 :(得分:1)
KML缓存的常用解决方案(以及Google在服务器上缓存数据几小时)是在URL中使用随机或基于时间的缓存清除参数(因此它永远不会相同)。
缓存清除参数的一个示例:
'?dummy=' + (new Date()).getTime());