Google Map V3 Click Event for multiple objects (marker, polygon...)

381 views
Skip to first unread message

7heroes

unread,
Oct 11, 2011, 6:26:23 PM10/11/11
to google-map...@googlegroups.com
Hi all,

I have an array of object (polygons), and each object has its own click event. I am successfully attached click event to each object which will trigger the same OnPolygonClick(e), however I don't know how to determine which polygon is clicked, something like if you click on a polygon which has property name = "Area 1", the infowindow will show "Area 1" as well as its other info and so on...is there a way to attach a custom object to a polygon which is sent from ASP.NET and when user click on it, the object info will be displayed?

Thanks,

Sam.

geoco...@gmail.com

unread,
Oct 11, 2011, 8:48:18 PM10/11/11
to Google Maps JavaScript API v3
This example uses function closure:
http://www.geocodezip.com/v3_polygon_example_clickable_squares.html

I'm sure there are other ways to do it also.

-- Larry
>
> Thanks,
>
> Sam.

7heroes

unread,
Oct 12, 2011, 11:46:02 AM10/12/11
to google-map...@googlegroups.com
Thanks Larry, work like a charm :).
Reply all
Reply to author
Forward
0 new messages