Althougth I knew that polygons are clickable, I had problems when I
wanted to use it in my programming.
How do I collect the information I need when a polygon has been
clicked?
When a polygon has been created, I add this listener to it.
GEvent.addListener(polyShape, "click", function(overlayobject) {
map.openInfoWindowHtml(overlayobject, infotext);
var j = this.getVertexCount(); // get the amount of points
for (var i = 0; i<j; i++) {
polyPoints[i] = this.getVertex(i); // update polyPoints array
}
polyShape = this;
});
polyShape, overlayobject, infotext and polyPoints are variables. You
may use your own names.
On Jun 18, 10:35 am, Mike Williams <[email protected]> wrote:
> Since September 2007, GPolygons have been clickable. You can listen for
> clicks in exactly the same way as you listen for marker clicks.
>
> Make sure that you obtain Function Closure on your polygon references
> (e.g. by using a createPoly() function to create the poly and the event
> listener) just like you would for GMarkers.
>
> --
> Mike Williamshttp://econym.org.uk/gmap
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---