ThinkGeo.com    |     Documentation    |     Premium Support

Exception Loading KML File

I was trying to load a KML file from the DesktopEditionSample KmlExtension example in my application, but I get the following exception on the map refresh.


The type initializer for 'xRM=.OxY=' threw an exception.


   at xRM=.OxY=.PhY=(String nodeLocalName)

   at ThinkGeo.MapSuite.Core.KmlFile.ReadStyles()

   at ThinkGeo.MapSuite.Core.KmlFile.Open()

   at ThinkGeo.MapSuite.Core.KmlFeatureSource.OpenCore()

   at ThinkGeo.MapSuite.Core.FeatureSource.Open()

   at ThinkGeo.MapSuite.Core.FeatureLayer.OpenCore()

   at ThinkGeo.MapSuite.Core.Layer.Open()

   at ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)

   at ThinkGeo.MapSuite.DesktopEdition.Overlay.sRM=(GeoCanvas canvas)

   at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)

   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.dRQ=(IEnumerable`1 drawingOverlays, RectangleShape extent)





       private void kMLToolStripMenuItem_Click(object sender, EventArgs e)

        {

                winformsMap1.Overlays.Clear();


                //Set the geography unit to decimal degrees, to defines how your map data is stored

                winformsMap1.MapUnit = GeographyUnit.DecimalDegree;


                winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

                winformsMap1.CurrentExtent = new RectangleShape(-122.0874, 37.4245, -122.0804, 37.4201);


                WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay();


                worldMapKitDesktopOverlay.Name = "worldMap";

                worldMapKitDesktopOverlay.MapType = WorldMapKitMapType.Road;

                winformsMap1.Overlays.Add("worldMap", worldMapKitDesktopOverlay);


                KmlFeatureLayer layer = new KmlFeatureLayer("C:\\ThinkGEO\\KmlExtensionSample\\App_Data\\KML_Samples.kml");

                layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Black), new GeoSolidBrush(GeoColor.SimpleColors.Yellow));

                layer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColor.SimpleColors.Blue, 5));

                layer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.SimpleColors.Green), 10);


                LayerOverlay stateOverlay = new LayerOverlay();

                stateOverlay.Layers.Add("KmlLayer", layer);

                winformsMap1.Overlays.Add("StateOverlay", stateOverlay);

                

                winformsMap1.Refresh();

        }



Thanks Jim



Hi Jim, 
  
 From your exception information, it looks like that’s because your KML file contains invalid type for us. 
  
 Could you please upload a small test KML so we can use your code for reproduce it? 
  
 Regards, 
  
 Don

I zip up the KML file, the file I am trying to load is the file from your sample program DesktopEditionSample KmlExtension. 



wiki.thinkgeo.com/wiki/File:…100623.zip



I am using Map Suite Desktop Edition 9.0



Thanks Jim


KML_Samples.zip (7.84 KB)

Hi James, 
  
 Thanks for your information, it looks we have put related code from KmlExtension into MapSuiteCore. 
  
 I tested that but found I cannot build index succeed. 
  
 I will look into it and any update will let you know. 
  
 Regards, 
  
 Don

Hi James,



Sorry for the waiting. It’s proved a bug and we fixed in the latest daily build, would you please try it? The fixed version should be 9.0.50.0 and 9.0.0.50.



Thanks,



Troy

Hi,  
 Has this been resolved? I’m using MapSuiteCore.dll v9.0.0.77 and am seeing the same issues as originally documented 
 Thanks 
 Steve

Hi Steve, 
  
 Thanks for the mention, I checked it again and there is an issue when we secure the source code, we are working on it now and should fix it soon. 
 I will update here once the new package is ready. 
  
 Regards, 
 Troy

Hi Troy,

Has this been addressed yet?

Thanks

Steve

Hi Steven, 
  
 I think it have been fixed, I tested the sample James mentioned, remove KmlExtension prject and it works well. 
  
 Does that still don’t works for you? 
  
 Regards, 
  
 Don

How we can download this version to solve the problem ? I am having similar problem of loading a kml file using 9.0.0.0

Hi Saeer,

Please download our product center, then get the latest development package like 9.0.x.0.

And if the issue still exist in the latest version please let us know. A simple sample which can reproduce that should be more helpful.

Regards,

Don