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

Elements Specific to LineStyle

Mar 26, 2012 at 2:00 AM

Hi. Is it possible to use <gx:outerColor>, <gx:outerWidth>, etc. with LineStyle?

Apr 15, 2012 at 11:24 PM

First let me appologise for the long delay in getting back to you.

Those elements look like they were introduced in Google Earth 6.0 At the moment the library doesn't support creating them (though neither does libkml by the looks of things). I don't really know what to suggest to you to do at the moment; I will open an issue and try to take a look at it over the next couple of weeks.

As a temporary hack, you could use the AddOrphan method of Element to attach any custom Element to the LineStyle (either change the access modifier in Element.cs to public or use reflection like below). Here is a very quick example on how to add it (though you'll probably want to add the GX22 namespace to the root Kml - see this documentation for more details):

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

namespace Examples
    public class OuterColor : Element, ICustomElement
        public Color32 Value { get; set; }

        public bool ProcessChildren
            get { return false; }

        public void CreateStartElement(System.Xml.XmlWriter writer)

    internal static class Program
        public static void Main(string[] args)
            LineStyle lineStyle = new LineStyle();
            AddOrphan(lineStyle, new OuterColor { Value = new Color32(255, 0, 255, 0) });

            // Show the example output.
            var serializer = new Serializer();

        private static void AddOrphan(Element parent, Element orphan)
            // TODO: Prehaps cache the MethodInfo?
            var method = parent.GetType().GetMethod("AddOrphan", BindingFlags.Instance | BindingFlags.NonPublic);
            method.Invoke(parent, new object[] { orphan });

Aug 16, 2012 at 2:18 PM

This worked well, I was able to add a 6.1 feature for line label visibility with relative ease.