Search code examples
kml

How do I use kml placemarker from file?


<href>drive location</href>

doesn't work, quite naturally. I haven't seen anywhere that actually addresses how to reference a hard drive location as where the placemark image is to be taken from. What is line of code I have to use to bring in an image from a hard drive?


Solution

  • The <href> tag in KML is used to represent a URL to the file location not the Windows absolute file location so http://server/myimage.png is valid but c:/myfiles/image.png is not.

    First try moving the image to the same folder as the KML file and refer to the image via a relative URL with just the filename.

    Example:

      <Style>
          <IconStyle>
             <Icon>
                <href>icon21.png</href>
             </Icon>
          </IconStyle>
      </Style>
    

    If want to represent an absolute file location as a URL then C:\myimages\image.png can be rewritten as file:///C:/mymages/image.png.