谷歌地图API信息窗口不显示内容 [英] Google Maps API InfoWindow not Displaying content

查看:199
本文介绍了谷歌地图API信息窗口不显示内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code是这样的:

My Code looks like this:

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'
            });
        }
    }
});

基本上它的基础上创建一个给定的地址串的单个地图上的一些标记。它增加了信息窗口中,关于点击打开的标记。

Basically it's creating some markers on a single map based on a given address-string. It adds an infoWindow to the markers that opens on click.

问题是:信息窗口显示空

Problem is: the infoWindow displays empty.

在这里截图:<一href=\"http://localhostr.com/files/h370JA0/Unbenannt.png\">http://localhostr.com/files/h370JA0/Unbenannt.png

PS:使用地图API V3

PS: Using Maps API V3

推荐答案

我只是碰到了同样的问题,并发现它的非常简单的原因:在信息窗口中的文本实际上是显示,但以白色为主色调,并因此,只是没有在白色背景可见。通过CSS给出了内容不同的颜色解决了这个问题对我来说。

I just ran into the same problem, and found the very simple cause of it: The text in the info window was actually displayed, but in white color, and therefore just not visible on the white background. Giving the content a different color via CSS solved the problem for me.

这篇关于谷歌地图API信息窗口不显示内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆