This project has moved. For the latest updates, please go here.

Get Placemark color from Style

Mar 1, 2013 at 12:17 PM
I've loaded and parsed my KML file:
Kml kml = file.Root as Kml;
                if (kml != null)
                {
                    List<Placemark> placemarks = new List<Placemark>();
                    ExtractPlacemarks(kml.Feature, placemarks);

                    foreach (Placemark placemark in file.Root.Flatten().OfType<Placemark>())
                    {
                        string roadName = placemark.Name;
But at this point I also want to extract the colour from the placemarks style, the cc1447ff value:
<Style id="DM">
<LineStyle>
<color>cc1447ff</color>'
<width>4</width>
</LineStyle>
</Style>

<Placemark>
<name>Test</name>
<styleUrl>#DM</styleUrl>
<MultiGeometry>
<LineString><tessellate>1</tessellate>
<coordinates>
Any ideas?

Thanks!
Coordinator
Mar 1, 2013 at 7:05 PM
I think the SharpKml.Engine.StyleResolver.CreateResolvedStyle() method may do what you want - it returns a Style that will be a combination of the StyleUrl and the StyleSelector of a Feature - you should be able to extract the colour information you want.

Hope it helps,
Sam