Как открыть различную информацию для каждого созданного мною полигона? Google maps api v3

Вот код, который я сейчас запускаю: пользователь может создать свой собственный полигон после того, как его полигоны будут показаны на карте. Я хочу отобразить некоторую информацию о каждом полигоне. Теперь я открываю инфоиндустрию, но я не могу получить информацию для разных полигонов

Есть предположения?

<?php foreach ($area->result() as $f):?> // Create an array with the coordanates of each area var area<?=$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 Field to the map. area<?=$f->id?>.setMap(map); google.maps.event.addListener(field<?=$f->id?>,'click',function(event){ infowindow.setContent(contentString); if (event) { point = event.latLng; } infowindow.setPosition(point); infowindow.open(map); }); google.maps.event.addListener(map, 'click', function() { infowindow.close(); }); <?php endforeach;?> var contentString = '<div id="content" class="h300 rad3">'+ '<div>'+ '</div>'+ '<h2 ><?=$f->name?> </h2>'+ '<div id="bodyContent">'+ '<div class="bgC m20l glow3cb rad3 h100 w350 inlineB vtop m15b m15r">' + ' '+ ''+ '<div class="inlineT vtop w180 m5l"> '+ '<div class="inlineT vtop m5l"> '+ '</div>'; var infowindow = new google.maps.InfoWindow({ content: contentString }); 

    Один из способов связать содержимое infoWindow с полигоном – использовать закрытие функции, как это сделано в этом примере (см. Функцию createClickablePoly). Если вам не нужна интерактивная боковая панель, вы можете упростить эту функцию:

     function createClickablePoly(poly, html) { var contentString = html; google.maps.event.addListener(poly,'click', function(event) { infowindow.setContent(contentString); infowindow.setPosition(event.latLng); infowindow.open(map); }); }