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);
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?