[Google Maps API v3] kml layer with polygon overlay layer click event bug?

1,075 views
Skip to first unread message

DmitryM

unread,
May 13, 2010, 6:44:24 PM5/13/10
to Google Maps JavaScript API v3
When I create a polygon overlay on top of my kml layer, the kml
click event is not triggered anymore. Map click event and polygon
click event however fires.
Is it expected behaviour?

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

pi5701

unread,
May 14, 2010, 4:24:54 AM5/14/10
to Google Maps JavaScript API v3
my problem/ question points in kinda same dirction:

http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/09b5eae70cf68909

soz for hijacking your post ;)

DmitryM

unread,
May 13, 2010, 8:17:24 PM5/13/10
to Google Maps JavaScript API v3
Nevermind, I figured it out. Just in case anyone is interested, here
is what is happening.

I was trying to 'select' a feature on a KML layer by creating Polygon
overlay on top of the KML file. It worked for the first time when I
click on the KML layer, but once Polygon overlay is created, KML click
event is not triggered. Even if you delete the overlay by setting the
map to NULL, KML click event is still not fired.

So, If you add a KML layer to the map first and then create a polygon
object for example, KML click event is not fired because it is
'blocked' by Polyline overlay. What I end up doing is 'precreating'
Polygon overlay first and only then add KML layer. In this case
everytime I create an Overlay layer, it is going to be under the KML
layer and I'm able to click on it.

So my question is if there is any way of controling zIndex of
overlays?

nlraley

unread,
Jun 15, 2010, 5:47:13 PM6/15/10
to Google Maps JavaScript API v3
Not sure if you need this functionality or not, but if you set the
clickable attribute to the polyline or polygon that you are creating
to false then it should work fine for you again.

The problem would be as you said, the polygon/polyline is being
created over the kml layer that you created. If it has a clickable
attribute set to true it is going to capture the click event as
opposed to the kml layer. This is one thing I miss with regards to
the older api was that the map click event returned the overlay and
the overlaylatlng, now click events just return a simple latlng. In
the old api you could check against the overlay or just pull the
overlaylatlng, but now you only get the latlng of the object you
clicked on. Your polygon/polyline is at the uppermost layer and
therefore it is capturing the event.

As far as I know there is no z-index available yet in api v3 for
polygons and polylines, only infowindows and markers.

Nathan Raley

unread,
Jun 15, 2010, 5:52:13 PM6/15/10
to Google Maps JavaScript API v3
I wanted to add a little insert.  There is a z-index for polygons and polylines but it only sets the z-index for these 2 objects with respect to other polygons and polylines, not for other overlays as of yet from what I can tell.

Nathan Raley

unread,
Jun 15, 2010, 5:58:57 PM6/15/10
to Google Maps JavaScript API v3
And sorry to keep adding posts, I hate not being able to edit t add something, but going along that northbound route you will find several triggers for this error.  It also appears to mess up the control for moving forward to the next pov location as well.  If you pan left or right it will fix the forward control but otherwise it is broken for the forward when it loads the next pov.

Nathan Raley

unread,
Jun 15, 2010, 5:59:29 PM6/15/10
to Google Maps JavaScript API v3
Oops, wrong discussion.  Disregard that.
Reply all
Reply to author
Forward
0 new messages