2010-02-23 81 views
5

很简单的问题。KML + Google地球:制作多边形或GroundOverlay可点击吗?

我有一些在KML中定义的多边形和GroundOverlay。有没有办法指定它们应该是可点击的,并且(至少在Google Earth中)在点击时弹出信息框或类似信息?

同样,是否可以给多边形/ GroundOverlays任何类型的鼠标悬停行为?例如更换图标或颜色时被挖空?

回答

10

是的。为地标提供名称和说明将使其成为Google地球中的可点击对象,并将打开一个显示两者的信息窗口。您可以使用样式地图创建翻转/鼠标悬停行为,下面是两个示例:

<?xml version="1.0" encoding="UTF-8"?> 
<kml xmlns="http://www.opengis.net/kml/2.2"> 
<Document> 
<name>Highlighted Icon</name> 
<description>Place your mouse over the icon to see it display the new 
     icon</description> 
<StyleMap id="exampleStyleMap"> 
    <Pair> 
    <key>normal</key> 
    <!-- you could also use a <styleUrl> here instead of inlining --> 
    <Style> 
     <PolyStyle> 
     <color>7dff0000</color> 
     </PolyStyle> 
    </Style> 
    </Pair> 
    <Pair> 
    <key>highlight</key> 
    <!-- you could also use a <styleUrl> here instead of inlining --> 
    <Style> 
     <PolyStyle> 
     <color>7dffffff</color> 
     </PolyStyle> 
    </Style> 
    </Pair> 
</StyleMap> 

<!-- and now, a Placemark that uses the StyleMap --> 
<Placemark> 
    <name>Roll over this polygon</name> 
    <description>this will show up when clicked</description> 
    <visibility>1</visibility> 
    <styleUrl>#exampleStyleMap</styleUrl> 
    <Polygon> 
    <tessellate>1</tessellate> 
    <altitudeMode>absolute</altitudeMode> 
    <outerBoundaryIs> 
     <LinearRing> 
     <coordinates> 
      -112.3372510731295,36.14888505105317,1784 
      -112.3356128688403,36.14781540589019,1784 
      -112.3368169371048,36.14658677734382,1784 
      -112.3384408457543,36.14762778914076,1784 
      -112.3372510731295,36.14888505105317,1784 
     </coordinates> 
     </LinearRing> 
    </outerBoundaryIs> 
    </Polygon> 
</Placemark> 
</Document> 
</kml> 
+0

谢谢!非常感激。 – DanM 2010-03-02 17:18:08

+0

一个问题:你可以分别为每个地标做两部分的风格吗?例如,拥有一个包含100张JPEG图像的库,并且在地图上放置了100个纯色多边形,每当您将鼠标放在其中一张上时,100张图像中的一张会出现在它的位置上? – DanM 2010-03-02 19:33:04

相关问题