如何在气球文本或描述文本中的 kml 脚本中引用另一个气球或描述部分的文本?

How do I refer in a kml script within a ballon-text or a description-text to the text from another ballon or description part?

我有一个带有一些地标的 KML 脚本,其中一些内容写在 "description" 部分(HTML 样式)。一切正常,但在某些描述部分我想包含一个 link/reference 指向 KML 脚本中另一个地标的描述部分。

当用户单击指向巴黎的地标时,将打开一个带有描述内容的气球(这已经可以正常工作了)。我想要实现的是,在此气球中,用户应该能够点击突出显示的单词,例如"let's move to Marseille",这样做之后巴黎气球应该关闭,而马赛气球 - 属于马赛地标的描述部分 - 应该打开。

这可能吗?我在文档或谷歌搜索中找不到任何相关信息。 (或者我太笨了,找不到它)。

干杯,艾玛

您可以在描述中使用特殊的 link 从一个地标 link 到另一个地标,其中一个地标引用另一个地标。该机制在 KML 标准中称为特征锚点。

注意 Paris 地标中的 URL 是 #marseille;balloonFlyto,其中目标地标的 "id" 属性是 "marseille",点击时要执行的目标操作是 "balloonFlyto".

这是完整的 KML,其中一个地标 link 指向另一个地标:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>feature anchor</name>
    <description>Feature anchor using ; to delimit action.</description>

    <Placemark id="paris">
      <name>Paris</name>
        <description>
        <![CDATA[ 
        let's move to <a href="#marseille;balloonFlyto">Marseille</a>
      ]]>
      </description>
      <Point>
        <coordinates>2.3508,48.8567</coordinates>
      </Point>
    </Placemark>

    <Placemark id="marseille">
      <name>Marseille</name>
      <description>
        <![CDATA[ 
        Welcome to Marseille.
        Return to <a href="#paris;balloonFlyto">Paris</a>       
      ]]>
      </description>
      <Point>
        <coordinates>5.37,43.2964</coordinates>
      </Point>
    </Placemark>

      </Document>
</kml>

弹出描述气球中的目标 href 可以是片段 URL(即带有 # 符号后跟 KML 标识符的 URL)。您还可以使用分号 (;) 和以下限定符之一将操作附加到 URL:

  • flyto(默认)- 飞往地图项
  • balloon - 打开地物的气球但不飞向地物
  • balloonFlyto - 打开地物的气球并飞向地物

以上摘自KML reference