Otwórz InfoWindow dla każdego wieloboku google maps V3

Mam nadzieję, że ktoś może mi pomóc w tej kwestii. Usiłuję otworzyć okna informacyjne na kliknięcie dla każdego wielokąta utworzonego przez moich użytkowników. Użyłem tego samego kodu dla znacznika i działa dobrze, ale nie mogłem sprawić, by działał dla każdego wielokąta.

Jakieś przemyślenia, jak rozwiązać ten problem?

Dzięki.

var contentString = '<div id="content">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h2>Test</h2>'+
    '</div>';

var infowindow = new google.maps.InfoWindow({
    content: contentString
});

// Pokaż obszary

<?php foreach ($field->result() as $f):?>

// Create an array with the coordanates of each area

var field<?=$f->id?>Coords = [
    <?php $latlng=$this->resources_data->field_latlng($f->id);?>
    <?php foreach ($latlng->result() as $point):?>
    new google.maps.LatLng(<?=$point->lat?>, <?=$point->lng?>),
    <?php endforeach;?>
];

// Create a polygon with the points of the area

var area<?=$f->id?>=new google.maps.Polygon({
    paths: area<?=$f->id?>Coords,
    strokeColor: '#FF0000',
    strokeOpacity: 0.8,
    strokeWeight: 2,
    fillColor: '#FF0000',
    fillOpacity: 0.35
});

// Add the area to the map.

area<?=$f->id?>.setMap(map);

google.maps.event.addListener(area<?=$f->id?>,'click',function(){
    infowindow.open(map,area<?=$f->id?>)
});

<?php endforeach;?>

questionAnswers(2)

yourAnswerToTheQuestion