Google Maps v3 API:KML图层与点击,鼠标事件混淆 [英] Google Maps v3 API: KML layer messing with click, mouse events

查看:217
本文介绍了Google Maps v3 API:KML图层与点击,鼠标事件混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个项目,在创建一些漂亮的代码以创建多边形并将鼠标事件附加到它们之后,添加KML图层(主要是放置标记)会导致KML图层占位符与生成的图片之间不协调的行为多边形。

如果我先创建多边形并在之后设置KML文件,则单击placeMarkkers会按预期调出infowindow()。但是,下面的多边形上的鼠标悬停不会产生任何结果,而在它们突出显示之前并且是可点击的(它们不是)。



将KML图层设置为null doesn'也没有帮助。



当我第一次使用地图标记调用KML时,稍后调用的多边形图层将位于地图标记的顶部。多边形是不透明的,所以您可以通过窗口看到地图标记,但不能单击或与地图标记进行交互。



将多边形设置为空导致与以前相同的行为。占位符仍然无法点击。



帮助?我无法找到KML图层代码的zIndex参考,我希望就是这样。我读过其他地方 - 并想象这是真实的 - KML和用户创建的内容层互相冲突 - 后者放在地图上需要注意焦点,捕捉事件等。我会想到的那就没什么关系了,就像你可以在其他div上使用div一样,特别是如果你使用索引。

如果您只是想在KML图层中显示信息而没有对用户事件做出反应,则可以将suppressInfoWindows标志添加到构造函数中:

  var myKmlLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml',{suppressInfoWindows:true}); 

这将有效地关闭所有互动并让其他图层接收互动。



编辑:忘记提及一个很好的信息来源是 Google API V3网站讨论KML图层


I'm working on a project where, after creating some nice code for creating polygons and attaching mouse events to them, the addition of KML layers (mainly placemarkers) results in uncooperative behaviour between the placeholders of the KML layer and the generated polygons.

If I create the polygons first and set the KML file afterwards, clicking on the placemarkers brings up the infowindow () as expected. However, mouseovers on the polygons below yield no result, whereas before they get highlighted and are clickable (which they aren't).

Setting the KML layer to null doesn't help either. The placemarkers disappear, but my polygons aren't registering.

When I first call the KML with placemarkers, the polygon layer called later goes on top of the placemarkers. The polygons are opaque, so you can see the placemarkers like you could through a window, but you can't click or interact with the placemarkers.

Setting the polygons to null results in the same behaviour as before. Placeholders still cannot be clicked on.

Help? I couldn't find a zIndex reference for the KML layer code, and I'm hoping that's all it is. I read somewhere else - and imagine this to be true - that the KML and user-gernated content "layers" are conflicting with one another - the latter one that's put on the map takes focus, captures events, etc. I would've thought that it wouldn't matter, in the same way that you can have divs on top of other divs, especially if you use indexing.

解决方案

If you simply want to display the information in the KML layer and not have it react to user events, you can add the suppressInfoWindows flag to the constructor:

 var myKmlLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml', { suppressInfoWindows: true });

This will effectively shut off all interactions and let your other layers receive interactions.

Edit: Forgot to mention that a good source of information is the Google API V3 site discussing KML layers

这篇关于Google Maps v3 API:KML图层与点击,鼠标事件混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆