多角形を動的に描画し、InfoWindow を開くために多角形をクリックしています。多角形を正常に描画していますが、Infowindow をクリックしても表示されません。エラーが発生しないようです。
これが私のすべてのコードです。
function ADD_EVENT_FOR_POLYLINE_AND_POLYGON () {
GLOBALS.PolyGonPath = new google.maps.MVCArray;
GLOBALS.PolyGon = new google.maps.Polygon({
strokeWeight: 3,
fillColor: '#5555FF'
});
GLOBALS.PolyGon.setMap(GLOBALS.Map);
google.maps.event.addListener(GLOBALS.Map, 'click', DRAW_POLYGON);
}
function DRAW_POLYGON(event) {
GLOBALS.PolyGonPath.insertAt(GLOBALS.PolyGonPath.length, event.latLng);
var marker = new google.maps.Marker({
position: event.latLng,
map: GLOBALS.Map,
draggable: true
});
GLOBALS.PolyMarkers.push(marker);
marker.setTitle("#" + GLOBALS.PolyGonPath.length);
google.maps.event.addListener(marker, 'click', function () {
marker.setMap(null);
for (var i = 0, I = GLOBALS.PolyMarkers.length; i < I && GLOBALS.PolyMarkers[i] != marker; ++i);
GLOBALS.PolyMarkers.splice(i, 1);
GLOBALS.PolyGonPath.removeAt(i);
});
google.maps.event.addListener(marker, 'dragend', function () {
for (var i = 0, I = GLOBALS.PolyMarkers.length; i < I && GLOBALS.PolyMarkers[i] != marker; ++i);
GLOBALS.PolyGonPath.setAt(i, marker.getPosition());
});
**Here is I am adding a method to polygon for infowindow**
GLOBALS.PolyGon.setPaths(new google.maps.MVCArray([GLOBALS.PolyGonPath]));
google.maps.event.addListener(GLOBALS.PolyGon, 'click', SHOW_INFO);
},
function SHOW_INFO (event) {
var infowin = new google.maps.InfoWindow();
var vertices = GLOBALS.PolyGon.getPath();
var contentString = "<b>Test</b><br />";
for (var i = 0; i < vertices.length; i++) {
var xy = vertices.getAt(i);
contentString += "<br />" + "Coordinats: " + i + "<br />" + xy.lat() + "," + xy.lng();
}
infowin = new google.maps.InfoWindow();
infowin.setContent(contentString);
infowin.setPosition(event.latLng);
infowin.open(GLOBALS.Map, this);
}