icons - 如何使用来自本地磁盘或网络驱动器的图像显示自定义 KML 地标图标

标签 icons kml google-earth

有谁知道如何使用来自本地磁盘或网络驱动器的图像显示自定义 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/

相关文章:

ios - 由于“缺少图标”,Apple Watch 提交失败

gps - 如何计算以GPS坐标为中心的地球圆上的点?

google-maps - 如何通过 "mid"参数从 Google Maps API 下载 KML 文件?

java - KML 在未挤压时出现线性环的高度问题

kml - 如何使 KML 不导入多几何顺序

eclipse - Eclipse 中的图标是什么意思?

java - 包含 Icon 的 JComboBox 在 Mac 上太小

android - 如何获得收藏之星

icons - 如何在 kml 中引用本地自定义图标?

KML 运动线方向