【问题标题】:How to Display Custom KML Placemark Icon using Image from Local Disk or Network Drive如何使用本地磁盘或网络驱动器中的图像显示自定义 KML 地标图标
【发布时间】:2014-06-19 17:36:41
【问题描述】:

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

谢谢

【问题讨论】:

    标签: icons kml google-earth


    【解决方案1】:

    KML 中的 &lt;href&gt; 元素采用 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:/etnasss.jpg)来引用图像,但 Google 地球有关于在 KML 上下文之外访问文件系统上的本地文件的安全政策文件。您必须允许访问通常不推荐的本地文件。

    或者,您可以创建一个KMZ file(又名 ZIP 文件)并将图像包含在 KMZ 存档文件中,并在 KML 文件中引用它。

    【讨论】:

    • 感谢您的回复。我可以在网络上的另一台机器上使用图标文件吗? href 可能类似于 \\ComputerNameOrIpAddress\ShareName\pic.jpg?
    • \\Computername 是 Windows 标识符而不是 URL。如果其他机器有 Web 服务器,那么您可以使用 URL machine....
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-17
    • 1970-01-01
    • 2017-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多