AnsweredAssumed Answered

Repetitive add and remove of KMLLayers

Question asked by rosie_as on Oct 7, 2015
Latest reply on Mar 18, 2016 by sandia_dedia

I got an assigment to add photo overlay on ArcGis Scene. Photo is updated after few seconds.

I couldn't find another solution, so I use KMLLayer, in following scenario:


  1-create temporary kml file with ground overlay object

  2-create KMLLayer with file uri

  3-add new layer to scene

  4-remove old one


First 3 steps are working smoothly, but when I try to remove old layer, application sometimes crashes (I can reproduce crashing with zooming and panning scene)


Code is bellow.



  private async void AddKMLLayer(string kml, string id, string oldid)


       await AddLayer(kml, id, SearchCompleted, oldid);


  private async Task AddLayer(string kml, string id, Action<KmlLayer> callback, string oldid)


       Uri sourceUri = new Uri(Environment.GetFolderPath(_folder + @"\" + id + ".kml");

       KmlLayer layer = new KmlLayer(sourceUri);

       layer.ID = id;

       _arcGISmapWPF.IkenaSceneView.IsEnabled = false;

       await layer.InitializeAsync();


       callback(layer, oldid);//add layer when initialized



  private void SearchCompleted(KmlLayer layer, string oldid)