This project has moved and is read-only. For the latest updates, please go here.

Icon, LatLonBox and Saving

Feb 22, 2012 at 10:31 AM

First I'd like to congratulate you for developing this great tool. Nevertheless I've got three problems with it:

1. Why is there a difference between IconStyle.IconLink myIcon and Icon myIcon (from groundoverlay)?

2. Extracting the values from a LatLonBox (example) I get only values without seperator. For this Example 485297877485518, 4393540532972251 and so on.


3. Saving a kml file, I've got only ANSI-Files where specific local language characters will be lost. Adding an default encoding solve this problem for me.

        public void Save(Stream stream)
            Serializer serializer = new Serializer();

            using (var writer = new StreamWriter(stream, System.Text.Encoding.Default))

Thanks in advance

Feb 22, 2012 at 11:26 AM

Hi Rainer,

Thanks for using the library! While there doesn't appear to be a difference between IconLink and Icon, the specification mandates two separate objects; §12.9 lists Icon as a special child of IconStyle and §13.1 lists Icon as effectively an alias for Link.

Regarding your second point, the following code works for me:

using System;
using SharpKml.Base;
using SharpKml.Dom;

public static class Program
    public static void Main(string[] args)
        const string kml =

        var parser = new Parser();
        parser.ParseString(kml, false);
        LatLonBox box = (LatLonBox)parser.Root;
        Console.WriteLine("North: {0}\nSouth: {1}\nEast:  {2}\nWest:  {3}",

However, looking through the source code and it appears as though the parsing might be sensitive to the current culture (i.e. if the above doesn't work for you try adding System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; before the call to parser.ParseStrin and see if that works). If changing the culture works can you let me know what your system language is so I can create a test case and fix the bug.

The last issue you mention isn't a problem with the serializer as it uses InvariantCulture - I think it's more an issue with storing the returned string.

Thanks again and if you can let me know about you language settings I'll get the code updated (I'm currently working on SilverLight support so it would be nice to update everything at the same time.)


Feb 22, 2012 at 12:15 PM

Hello Sam,

I'm excited about this quick response!

Your example didn't work for me either. After adding the CurrentCulture setting it worked. By the way, reading coordinates results the right values, this problem occurs only with the LatLonBox.

At last, I'm from Germany got a lot of ÄÖÜ...

Thank you very much!


Feb 22, 2012 at 12:46 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.