Search code examples
c#google-earth-plugin

How do you change the icon of a placemark entry in a KMLTreeView using the GE Winforms API


I would like to be able to change the icon of placemark entry in a KMLTreeView from a flag to some other custom bitmap. It is not readily apparent to me that this can be done but if someone knows how can you please provide a few lines of code?

Here is a pic of the 'flag' I would like to change.

enter image description here

And here is the code that appears to set this icon. I cannot find where the string "flag" is converted to an image. This code is from the file KmlTreeViewNode.cs of the API dated 11/20/2012:

    internal void SetStyle()
    {
        switch (this.ApiType)
        {
            // other lines of code //

            case ApiType.KmlPlacemark:
                {
                    this.ImageKey = "flag";
                    this.SelectedImageKey = "flag";
                }
            // more lines of code //

Thank you for any help you can offer.


Solution

  • You would need to replace the flag image file with your desired file and then recompile the library.

    The image itself is a 16x16 pixel bitmap and is stored in an ImageList within the KmlTreeView control. Simply replace the flag image with the one you desire (remove the flag image then add a new image at index 2) then recompile the library.

    KmlTreeView Image list collection editor

    Alternatively you can simply add a new ImageList to the KmlTreeView. If you do this you should make sure that the images have the same names and indices.

    kmlTreeView1.ImageList = this.myImageList;