views:

361

answers:

1

Help!

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.

A: 

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

Tony Miller
Thanks Tony. Thing is, I do want the InfoWindows for the KML layer - otherwise, they're no more than data points.I suppose I could try to create Infopoints and emulate them over the KML layer, but at that point it'd be easier to just generate markers.
Eugene