1

我正在加载 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);

我尝试了 KmlLayer.Refresh();

我需要通过代码清除浏览器缓存还是可以加载新数据?

4

1 回答 1

1

KML 缓存的常用解决方案(谷歌在服务器上缓存数据几个小时)是在 URL 中使用随机或基于时间的缓存破坏参数(因此它永远不会相同)。

缓存破坏参数的一个示例:

'?dummy=' + (new Date()).getTime()); 
于 2012-10-10T13:28:17.763 回答