KMZ 文件 Google 地图 v3 中的多边形突出显示/鼠标悬停损坏
我正在尝试使用 Google 地图 v3 使突出显示/悬停/鼠标悬停样式适用于 KMZ 地标。当我使用 Google Earth 打开 KMZ 文件时,悬停时的相应区域将更改为预期的highlightPlacemark 样式。但是当我将此 KMZ 加载到 Google 地图对象上时,样式永远不会改变。
样式如下:
<Style id="highlightPlacemark">
<LineStyle>
<color>ff000000</color>
</LineStyle>
<PolyStyle>
<color>a60000ff</color>
</PolyStyle>
</Style>
<StyleMap id="exampleStyleMap">
<Pair>
<key>normal</key>
<styleUrl>#normalPlacemark</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#highlightPlacemark</styleUrl>
</Pair>
</StyleMap>
<Style id="normalPlacemark">
<LineStyle>
<color>ff000000</color>
</LineStyle>
<PolyStyle>
<color>a6ffffff</color>
</PolyStyle>
</Style>
地标如下所示:
<Placemark id="1">
<name>Test</name>
<Snippet maxLines="0"></Snippet>
<styleUrl>#exampleStyleMap</styleUrl>
<Polygon>
<extrude>1</extrude>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
...lots of coordinates here...
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
此功能仅适用于 Google 地球,还是有解决方法使其适用于 Google 地图 v3? 我能想到的唯一方法是创建单独的 Polygon 对象,并分别为它们提供坐标。这允许您使用 Polygon 类的鼠标悬停事件。不过,我宁愿将所有多边形放在 1 个文件中...
提前致谢!
I'm trying to get the highlight/hover/mouseover styles working for a KMZ Placemark using Google Maps v3. When I open the KMZ file with Google Earth, the appropriate area when hovered will change to the highlightPlacemark style as intended. But when I load this KMZ onto a Google Map object, the style never changes.
Here is what the styles look like:
<Style id="highlightPlacemark">
<LineStyle>
<color>ff000000</color>
</LineStyle>
<PolyStyle>
<color>a60000ff</color>
</PolyStyle>
</Style>
<StyleMap id="exampleStyleMap">
<Pair>
<key>normal</key>
<styleUrl>#normalPlacemark</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#highlightPlacemark</styleUrl>
</Pair>
</StyleMap>
<Style id="normalPlacemark">
<LineStyle>
<color>ff000000</color>
</LineStyle>
<PolyStyle>
<color>a6ffffff</color>
</PolyStyle>
</Style>
Here is what the Placemark looks like:
<Placemark id="1">
<name>Test</name>
<Snippet maxLines="0"></Snippet>
<styleUrl>#exampleStyleMap</styleUrl>
<Polygon>
<extrude>1</extrude>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
...lots of coordinates here...
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
Does this feature only work in Google Earth or is there a workaround to make it work in Google Maps v3?
The only way I can think of is to create individual Polygon objects, and providing the coordinates to them individually. This allows you to use the mouseover event of the Polygon class. I would rather have all my Polygons in 1 single file though...
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我意识到这是一个非常古老的问题,但认为它可能对某人有帮助。 Google 地图并不支持所有 KML 标签。 (Google 地球支持大多数(如果不是全部的话)。)例如:
Google 地图不支持,但可以在地球中使用。所以这就是它不起作用的原因。
我目前也在寻找 Google 地图中 KML 多边形悬停状态的解决方案。 (没有额外的 javascript 或混乱的重复解决方法。)但这不是首要任务,所以如果我很快找不到解决方案,我现在就暂时不使用该功能。
I realize this is a very old question but thought it might help someone. Not all KML tags are supported in Google Maps. (Most if not all are supported in Google Earth.) For example:
is not supported in Google Maps but works in Earth. So this is why it doesn't work.
I'm currently looking for a solution to hover state for KML polygons in Google Maps as well. (Without additional javascript or messy duplicate workarounds.) But it's not top priority, so if I can't find I a solution soon I'll just do without that feature for now.
此问题已在 Google 地图 API 问题跟踪器上报告为 #131 这里。
该问题已关闭,除了“WontFix”之外没有任何评论/原因。
KmlLayers 被渲染为图块,所以我想这使得使用鼠标悬停事件变得更加困难。
This issue has been reported on the Google Maps API Issues tracker as #131 seen here.
The issue was closed without a comment/reason other than "WontFix".
KmlLayers are rendered as tiles, so I guess this makes it harder to use mouseover events.