如何将翻转状态添加到覆盖



我在地图上添加了一个覆盖层,并更改了覆盖层的颜色。我想知道是否可以将悬停事件添加到覆盖中?基本上,当你悬停在美国的一个州上空时,如果它是蓝色的,它就会变成绿色。诸如此类的东西。这就是我现在拥有的。

http://www.opsdivina.net/soum/

提前感谢

我认为这会奏效!

google.maps.event.addListener(polygon,"mouseover",function(){
this.setOptions({fillColor: "#00FF00"});
tooltip.style.visibility = 'visible';
}); 
google.maps.event.addListener(polygon,"mouseout",function(){
this.setOptions({fillColor: "#FF0000"});
tooltip.style.visibility = 'hidden';
});

以下链接将有所帮助!http://econym.org.uk/gmap/example_mouseover.htm,http://philmap.000space.com/gmap-api/poly-hov.html,http://econym.org.uk/gmap/example_hoverchange75.htm

http://groups.google.com/group/kml-support-getting-started/browse_thread/thread/66e7a7ab1b269104/d050e85ab54679a1

出于某种原因,下面的报价没有直接格式化,并且跳过了一些xml,所以您只想转到上面列出的链接来获得确切的解决方案。尝试在此处正确格式化。

如果要在鼠标悬停时高亮显示多边形,则需要添加样式映射到具有该多边形几何体的特征。

这里有一个例子:

<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2"> 
    <Document> 
        <Style id="sn_style"> 
          <PolyStyle> 
            <color>00ff8080</color> 
            <fill>0</fill> 
          </PolyStyle> 
        </Style> 

        <Style id="sh_style"> 
          <PolyStyle> 
            <color>7fff8080</color> 
          </PolyStyle> 
        </Style> 

        <StyleMap id="msn_style"> 
            <Pair> 
                <key>normal</key> 
                <styleUrl>#sn_style</styleUrl> 
            </Pair> 
            <Pair> 
                <key>highlight</key> 
                <styleUrl>#sh_style</styleUrl> 
            </Pair> 
        </StyleMap> 

      <Placemark> 
        <name>Polygon with fade in/out</name> 
        <styleUrl>#msn_style</styleUrl> 
        <Polygon> 
          <outerBoundaryIs> 
            <LinearRing> 
              <coordinates> 
                138.64,-34.93 138.64,-34.94 138.63,-34.94 138.62,-34.94 
                138.62,-34.95 138.62,-34.96 138.61,-34.97 138.60,-34.97 
                138.59,-34.97 138.58,-34.97 138.57,-34.97 138.57,-34.96 
                138.57,-34.95 138.57,-34.94 138.57,-34.93 138.57,-34.92 
                138.57,-34.91 138.56,-34.91 138.56,-34.90 138.57,-34.90 
                138.57,-34.89 138.56,-34.88 138.57,-34.88 138.58,-34.87 
                138.58,-34.86 138.58,-34.85 138.60,-34.85 138.61,-34.85 
                138.63,-34.85 138.64,-34.86 138.64,-34.87 138.63,-34.87 
                138.63,-34.88 138.62,-34.88 138.62,-34.89 138.63,-34.89 
                138.63,-34.90 138.64,-34.90 138.64,-34.91 138.64,-34.92 
    138.64,-34.93 
              </coordinates> 
            </LinearRing> 
          </outerBoundaryIs> 
        </Polygon> 
      </Placemark> 
    </Document> 
    </kml>

您还可以将该技术与区域相结合,以便仅在多边形在用户视图中处于"活动"状态。示例位于http://kml-samples.googlecode.com/svn/trunk/kml/Region/

相关参考文献:http://code.google.com/apis/kml/documentation/kmlreference.html#stylemaphttp://code.google.com/apis/kml/documentation/kmlreference.html#region

KMZ和KML中的悬停状态在V3中不起作用。真正做到这一点的唯一方法是在脚本中直接调用多边形。这样做将允许您以内联方式添加侦听器。

最新更新