AnsweredAssumed Answered

Constantly update KmlLayer from file

Question asked by jasonMDSP on Aug 12, 2015
Latest reply on Aug 23, 2015 by j.buchtaesri-de-esridist

I have a simple code that gets a Kml String, writes it to a file, and then adds it to the kmlLayer. In the KML strings I receive, I have a placemark that updates the position of a vehicle. Is there a way to efficiently update that Kml object constantly, without having to remove the KmlLayer and add a new one. It doesn't have to be a fluid animation, I just want to see the placemark updating quickly. My current implementation looks like this:

 

public string AddKmlObject(KmlObject kmlObj, string folderPath, string oldObjectId)
{
    try
    {
        if (kmlObj != null)//ArcGis does not support KML Strings, so I write KML into a file
         {
            System.IO.File.WriteAllText(_tempFilePath, kmlObj.ToKml());//Converts object to Kml Text
               
            KmlLayer kmlLayer = new KmlLayer(new Uri(_tempFilePath));
            kmlLayer.ID = kmlLayer.GetHashCode().ToString();

            IkenaSceneView.Scene.Layers.Add(kmlLayer);
   
            if (oldObjectId != "")
                MySceneView.Scene.Layers.Remove(oldObjectId); //Remove previous Kml
               
            return kmlLayer.ID;
         }      
    }
    catch
    {

    }
    return "";   
}

 

Is there a better way to do this?

Outcomes