有谁知道如何使用来自本地磁盘或网络驱动器的图像显示自定义 KML 地标图标。
我试过这个,但它不起作用:
<?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>
谢谢
最佳答案
<href>
KML 中的元素采用 URL 而不是 Windows 文件路径。 URL 可以是绝对或相对位置。
要使其正常工作,建议您首先将 KML 文件和图像移动到同一文件夹,然后通过其文件名引用图像。
<Style id="icon">
<IconStyle>
<Icon>
<href>etnasss.jpg</href>
</Icon>
</IconStyle>
</Style>
来源:https://developers.google.com/kml/documentation/kmlreference#href
接下来,您可以通过其绝对位置(例如 file:///C:/etnass.jpg)来引用图像,但 Google 地球具有关于访问 KML 文件上下文之外的文件系统上的本地文件的安全策略。您必须允许访问通常不推荐的本地文件。
或者,您可以创建一个 KMZ file (又名 ZIP 文件)并将图像包含在 KMZ 存档文件中并在 KML 文件中引用它。
关于icons - 如何使用来自本地磁盘或网络驱动器的图像显示自定义 KML 地标图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24312968/