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

Relative URI for IconLink Property

May 30, 2013 at 12:29 PM
I am creating a KMZ which includes a PNG file used by a KML within the archive. So I need to set the IconLink property for an icon object. I can use an absolute URI without any problems but when I try to use this:
kmlStyle.Icon.Icon = New SharpKml.Dom.IconStyle.IconLink(New System.Uri("icons/ship5.png", UriKind.Relative))
the kml file ends up with this as the URI:
when what is needed is this:
How can I specifiy a relative URI to point to a resource within the parent KMZ archive file.

May 30, 2013 at 9:58 PM
It looks like that should work, though I remember I had to do strange things to the URI when reading back from Kmz archives.

Do you have a minimal sample you could either post below or email across (use the Contact link on my profile) and I will take a look at it.

May 31, 2013 at 2:59 PM
Edited May 31, 2013 at 2:59 PM

Many thanks for your reply. In the process of putting together a minimal sample I found the problem. I just had the relative path wrong, I needed "../icons/ship5.png" instead of "icons/ship5.png" because the KML is in it's own subfolder (there are, in fact, many KMLs in a subfolder with the main doc.kml just having network links to them).

In case it helps anyone else, if you look at the XML by copying the feature in Google Earth and pasting into a text editor, you get the absolute path (as above). If you open the actual KML in a text editor it shows the relative path which was how I was able to spot the problem.

Thanks for you help, Sam, and I hope I haven't wasted too much of your time.