How to Display Custom KML Placemark Icon using Image from Local Disk or Network Drive
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.
honor
I am spending most of my time at work on Apache Spark, DASK & Kubernetes. Apart from that, I am developing a social app using React-Native, Firestore, Redux, FCM and Google Cloud Functions.
Updated on August 24, 2020Comments
-
honor over 3 years
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
-
honor almost 10 yearsThanks for the reply. Could I use icon files on another machine on the network? Could href be something like \\ComputerNameOrIpAddress\ShareName\pic.jpg?
-
CodeMonkey almost 10 years\\Computername is a windows identifier not a URL. If other machine has a web server then you can use the URL machine....