Pergunta

I'm loading the ESRI Map and the KML Layer Everything Works Fine!

Problem : After the KML Data changes(often changes), i am unable to show the New Changes in the Map. I need to forcefully Clear the Browser Cache every time.And I tried refreshing the layer did't work out.

My code

// 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);

I tried theKmlLayer.Refresh();

Do i need to clear the Browser cache through code or is it possible to load the new data?

Foi útil?

Solução

The usual solution to KML caching (and Google caches the data for a few hours on the server), is to use a random or time based cache busting parameter in the URL (so it is never the same).

one example of a cache busting parameter:

'?dummy=' + (new Date()).getTime()); 
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top