私のコードは次のようになります。
var map = /*some google map - defined earlier in the code*/;
var geocoder = new google.maps.Geocoder();
var address = 'Some Address, Some Street, Some Place';
geocoder.geocode({'address':address},function(results,status){
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var infobox = new google.maps.InfoWindow({
content: 'Hello world'
});
for(i in results){
var marker = new google.maps.Marker({
map: map,
position: results[i].geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
infobox.setContent('blablabla');
infobox.open(map,marker);
alert(infobox.content); //displays 'blablabla'
});
}
}
});
基本的に、指定された住所文字列に基づいて、単一のマップ上にいくつかのマーカーを作成しています。クリックすると開くマーカーに infoWindow を追加します。
問題は、infoWindow に何も表示されないことです。
スクリーンショットはこちら:
PS: Maps API V3 の使用