Google Maps API InfoWindow不显示内容

Tom*_*lde 9 google-maps infowindow google-maps-api-3 geocode

我的代码看起来像这样:

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'
            });
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

基本上它是基于给定的地址字符串在单个地图上创建一些标记.它会向单击时打开的标记添加infoWindow.

问题是:infoWindow显示为空.

截图:

截图

PS:使用Maps API V3

小智 23

我刚遇到同样的问题,并找到了它的非常简单的原因:信息窗口中的文本实际上是显示的,但是是白色的,因此在白色背景上看不到.通过CSS为内容提供不同的颜色解决了我的问题.


Mic*_*hal 2

基本上,您需要使用标记添加循环外部的函数将信息框消息添加到每个标记...有关示例和详细说明,请参阅: http://code.google.com/apis/maps/documentation/javascript /events.html#EventClosures