【问题标题】:How to enable highlighting on a line KMZ in Google Earth?如何在 Google 地球的 KMZ 线上启用突出显示?
【发布时间】:2020-02-12 19:37:13
【问题描述】:

我试图弄清楚如何在 Google 地球中将鼠标悬停在一条线段上时突出显示它。

当我将鼠标悬停在它上面时,这就是它目前的样子。请注意,整行保持蓝色: Imgur

当我将鼠标悬停在它上面时,我希望它看起来像这样。该段应该改变颜色: Imgur

有没有办法用代码做到这一点?我需要将其转换为其他文件类型吗?

【问题讨论】:

    标签: gis geospatial pipeline google-earth kmz


    【解决方案1】:

    要在您将鼠标悬停在 Google 地球上或将鼠标悬停在其上时更改一条线,那么您需要 KML 定义一个 StyleMap,其样式用于“正常”模式,另一个用于“突出显示”模式。

    在下面的示例中,该线默认显示为正常样式的蓝色细线,但当您将鼠标悬停在该线上时会变为较粗的紫色线,然后切换为突出显示样式。

    例子:

    <?xml version="1.0" encoding="utf-8"?>
    <kml xmlns="http://www.opengis.net/kml/2.2">
      <Document>
           <Style id="sn">
              <LineStyle>
                <color>7fff0000</color>         
                <width>2</width>
              </LineStyle>
              <PolyStyle>
                <color>7fff0000</color>
              </PolyStyle>
            </Style>
            <Style id="sh">         
              <LineStyle>
                <color>7fff00ff</color>
                <width>8</width>
              </LineStyle>
              <PolyStyle>
                <color>7f00ff00</color>
              </PolyStyle>
            </Style>          
            <StyleMap id="msn">
                <Pair>
                    <key>normal</key>
                    <styleUrl>#sn</styleUrl>
                </Pair>
                <Pair>
                    <key>highlight</key>
                    <styleUrl>#sh</styleUrl>
                </Pair>
            </StyleMap>
    
        <Placemark>
          <name>Style Map example</name>
          <styleUrl>#msn</styleUrl>
          <LineString>
            <tessellate>1</tessellate>
            <altitudeMode>absolute</altitudeMode>
            <coordinates>
              -112.265654928602,36.09447672602546,2357
              -112.2660384528238,36.09342608838671,2357
              -112.2668139013453,36.09251058776881,2357
              -112.2677826834445,36.09189827357996,2357
              -112.2688557510952,36.0913137941187,2357
              -112.2694810717219,36.0903677207521,2357
              -112.2695268555611,36.08932171487285,2357
              -112.2690144567276,36.08850916060472,2357
              -112.2681528815339,36.08753813597956,2357
              -112.2670588176031,36.08682685262568,2357
              -112.2657374587321,36.08646312301303,2357
            </coordinates>
          </LineString>
        </Placemark>
      </Document>
    </kml>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多