How to Display Custom KML Placemark Icon using Image from Local Disk or Network Drive
Asked Answered
V

1

5

Does anybody know how to display custom KML Placemark icon using image from local disk or network drive.

I tried this and it is not working:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Style id="icon">
        <IconStyle>
          <Icon>
            <href>c:\etnasss.jpg</href>
          </Icon>
        </IconStyle>
 </Style>
  <Placemark>
    <name>Simple placemark</name>
    <description>Attached to the ground. Intelligently places itself 
       at the height of the underlying terrain.</description>
    <styleUrl>#icon</styleUrl>    
    <Point>
      <coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
    </Point>
  </Placemark>
</kml>

Thanks

Vanitavanity answered 19/6, 2014 at 17:36 Comment(0)
O
9

The <href> element in KML takes a URL not a Windows file path. The URL can be an absolute or relative location.

To get it working, suggest you first move the KML file and the image to the same folder then refer to the image by its filename.

<Style id="icon">
    <IconStyle>
        <Icon>
          <href>etnasss.jpg</href>
        </Icon>
    </IconStyle>
</Style>

Source: https://developers.google.com/kml/documentation/kmlreference#href

Next, you could refer to the image by its absolute location (e.g. file:///C:/etnasss.jpg) but Google Earth has security policy regarding access to local files on the file system outside the context of the KML file. You'd have to allow access to local files which generally is not recommended.

Alternatively, you could create a KMZ file (aka ZIP file) and include the image within the KMZ archive file and reference it in the KML file.

Overcoat answered 20/6, 2014 at 12:31 Comment(2)
Thanks for the reply. Could I use icon files on another machine on the network? Could href be something like \\ComputerNameOrIpAddress\ShareName\pic.jpg?Vanitavanity
\\Computername is a windows identifier not a URL. If other machine has a web server then you can use the URL machine....Overcoat

© 2022 - 2024 — McMap. All rights reserved.