Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 416
honor Avatar asked Jun 19 '14 17:06

honor


People also ask

How do I change the icon of a KML file?

If you want to do it at the Folder level, right-click the Folder, select Properties (or Get Info), and go to the Style,Color tab. There you should see a Share Styles button which will make the styles for everything in that folder the same. Then use the icon button to select the icon.

How does a KML file work?

KML is a file format used to display geographic data in an Earth browser such as Google Earth. KML uses a tag-based structure with nested elements and attributes and is based on the XML standard. All tags are case-sensitive and must appear exactly as they are listed in the KML Reference.

What is KML KMZ files?

KML is an open standard of the Open Geospatial Consortium (OGC). KML can include both raster and vector data, and the file includes symbolization. KML files are like HTML, and only contains links to icons and raster layers. A KMZ file combines the images with the KML into a single zipped file.


1 Answers

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.

like image 69
CodeMonkey Avatar answered Jan 03 '23 12:01

CodeMonkey