AnsweredAssumed Answered

kmllayer.initialize() throwing exception for some kml layers

Question asked by humzarr on Jul 31, 2014
Latest reply on Dec 31, 2015 by NManocha-esristaff

i want to display the global gravity data which is in the form of Kml. the link to the file is given below:

ftp://topex.ucsd.edu/pub/global_grav_1min/global_grav.kmz

I wrote a small code using ARcGIS API for WPF and tried to initialize this kml file but I received this exception on running the code:

 

07/31/2014 13:37:39 | Fatal | App | Object reference not set to an instance of an object.

STACKTRACE:    at ESRI.ArcGIS.Client.Toolkit.DataSources.KmlLayer.Refresh()

   at ESRI.ArcGIS.Client.Toolkit.DataSources.KmlLayer.Initialize()

   at ESRI.ArcGIS.Client.GroupLayerBase.Initialize()

   at ESRI.ArcGIS.Client.Toolkit.DataSources.KmlLayer.backgroundWorker_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e)

   at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)

   at System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) | Object reference not set to an instance of an object. |  | Dispatcher.CatchExceptionStatic => Dispatcher.CatchException => App.App_DispatcherUnhandledException

 

 

As we can see that the exception is thrown by ArcGIS API internal functions. My code is given below:

 

var kmlLayer = new KmlLayer

            {

                Url = new Uri(@"D:\global_grav.kml", UriKind.Absolute),

                ID = "Kml_Samples",

                VisibleLayers = new[] { "*" },

               

            };  // I downloaded the file and converted it to kml

 

kmlLayer.Initialize(); // this is where the exception is thrown.

 

Any ideas about what might be causing this behavior? Any help would be highly appreciated.  Thanks

Outcomes