If I can be a little late with another solution, I had the same problem and I found that you can define custom properties on a polygon.
My example (which creates state on a US map)
poly = new google.maps.Polygon({ map_state_id: map_state_id, paths: pts, fillColor: colour, fillOpacity: 0.66, strokeWeight: 1, clickable:true });
In this case, map_state_id is a custom property. I defined it as a state identifier (1 for Alabama, 2 for Alaska, etc.).
Then, when the specific state is clicked later, this "map_state_id" can be passed to the event function.
google.maps.event.addListener(poly, 'click', function() { var map_state_id = this.map_state_id; //retrieve correct state_id $.ajax( { type: "POST", url: "http://www...get_state_info.php", data: {state_id : map_state_id}, dataType: "html", success: function(data) { $("#state_info").html(data); //display some info } }); });
I found this specific concept at http://dominoc925.blogspot.com/2011/12/add-your-own-property-field-to-google.html
source share