Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Sorry for my English.
I have already read this post , but I can't understand how to do the same in my case. I'm new in Javascript and it is my first job.

function addpolygon(n11,n12,n21,n22,n31,n32,n41,n42,n51,n52,info){
     var Coords = [
     new google.maps.LatLng(n11,n12),
     new google.maps.LatLng(n21,n22),
     new google.maps.LatLng(n31,n32)];
     if (n41 != "" && n42 != "") { 
     Coords.push(new google.maps.LatLng(n41,n42))}
     if (n51 != "" && n52 != "") {
     Coords.push(new google.maps.LatLng(n51,n52))}
          
     NewPolygon = new google.maps.Polygon({
     paths: Coords,
     strokeColor: "#FF0000",
     strokeOpacity: 0.8,
     strokeWeight: 2,
     fillColor: "#FF0000",
     fillOpacity: 0.35
     });
     
     NewPolygon.setMap(map);
     
     polygonsArray.push(NewPolygon);
     
     // Add a listener for the click event
     google.maps.event.addListener(NewPolygon, 'rightclick', showInfo);

     infowindow = new google.maps.InfoWindow();
     infowindow.setContent(info);
   }

function showInfo(event){
    infowindow.setPosition(event.latLng);
   	infowindow.open(map);
   }

function deletePolygons() { 
    if (polygonsArray) {
    for (j in polygonsArray) {
      polygonsArray[j].setMap(null);
      }
    polygonsArray.length = 0;
    }
   }


I call function "addpolygon" every time when want to create new polygon with some coords and different info. I push polygons in array to delete them in future. What I must to do if I want to show info's with each polygon?
Posted
Comments
SarethDark 4-Dec-10 4:12am    
somehow link to the post that I have read, don't appeared, so here it is
http://www.codeproject.com/Questions/93941/Infowindow-with-each-polygon.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900