Описание: sample google map с тремя полигонами. Я устанавливаю InfoWindow для каждого полигона, как,Google map infowindow position
for (var i in coordinates) {
arr = [];
for (var j=0; j < coordinates[i].length; j++) {
arr.push(new google.maps.LatLng(
parseFloat(coordinates[i][j][0]),
parseFloat(coordinates[i][j][1])
));
bounds.extend(arr[arr.length-1])
}
// Construct the polygon.
polygons.push(new google.maps.Polygon({
paths: arr,
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35
}));
polygons[polygons.length-1].setMap(map);
var infowindow = new google.maps.InfoWindow({
content:"Hello World!"
});
google.maps.event.addListener(polygons[polygons.length-1], 'click', function(event) {
infowindow.open(map);
infoWindow.setPosition(event.latLng);
});
}
Но InfoWindow показывает в верхнем левом положении. Как я могу установить его в центре щелкнутого многоугольника?
возможно дубликат (http://stackoverflow.com/questions/30930166/how-to-update-kml-file-layer-dynamically) – geocodezip