我已经向地图添加了一个覆盖图,并更改了覆盖图的颜色。我想知道有没有可能添加一个悬停事件到覆盖?基本上,当你将鼠标悬停在一个美国的州上时,如果它是蓝色的,它就会变成绿色。诸如此类的东西。这就是我现在所拥有的。
http://www.opsdivina.net/soum/
提前感谢
发布于 2012-04-06 00:26:22
http://groups.google.com/group/kml-support-getting-started/browse_thread/thread/66e7a7ab1b269104/d050e85ab54679a1
由于某些原因,下面的引号没有直接格式化,并跳过了一些xml,所以您只想转到上面列出的链接以获得确切的解决方案。尝试在这里正确地格式化它。
如果要在鼠标悬停时亮显多边形,则需要将StyleMap添加到具有该多边形几何体的要素。
下面是一个例子:
<?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#stylemap http://code.google.com/apis/kml/documentation/kmlreference.html#region
https://stackoverflow.com/questions/10032207
复制相似问题