Google地图.InfoWindow设置高度和宽度 [英] Google Map .InfoWindow Set Height and Width

查看:2719
本文介绍了Google地图.InfoWindow设置高度和宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置google地图的大小和宽度 InfoWindow ?我在api页面上 ,只找到了一个 maxWidth 方法。



编辑:我尝试过几个操作。到目前为止这些都没有工作:

  var markerInfoWindow = new google.maps.InfoWindow({
content:markerHTMLString,
maxHeight:400,//不工作
maxWidth:400,//不工作
width:300,//不工作
height:300 / /不工作
});

也说 markerHTMLString 等于:



< div class =MarkerPopUp>< div class =MarkerContext> Text< / div>< / div> ;



我尝试过这三个选项(都没有工作)



1)

  .MarkerPopUp 
{
height:300px;
width:300px;
}

2)

  .MarkerPopUp 
{
height:300px;
width:300px;
}

.MarkerContext
{
height:300px;
width:300px;
}

3)

  .MarkerContext 
{
height:300px;
width:300px;
}

这也不起作用:

  document.getElementById('MarkerPopUp')parentNode.style.overflow =''; 

或此

 code> document.getElementById('MarkerPopUp')。parentNode.parentNode.style.overflow =''; 

我几乎可以通过每个线程找到并尝试一切。只是为了限制一些事情(虽然可能有另一个问题)

解决方案

可能是当html传递地图api并解析出它没有访问你的样式表delcarations。尝试在MarkerPopUp上添加您的宽度作为内联样式。

 < div class =MarkerPopUpstyle =width:300px; >< div class =MarkerContext> Text< / div>< / div> 



我知道,我讨厌内联样式,但它可以解决你的问题。 p>

How do you set the size and width of a google map InfoWindow? I looked on the api page and only found a maxWidth method.

Edit: I have tried a few things. So far none of these work:

    var markerInfoWindow = new google.maps.InfoWindow({
        content: markerHTMLString,
        maxHeight: 400,  //Doesn't work
        maxWidth: 400,   //Doesn't work
        width: 300,      //Doesn't work
        height: 300      //Doesn't work
    });

Also say markerHTMLString is equal to this:

<div class = "MarkerPopUp"><div class = "MarkerContext">Text</div></div>

I have tried these three options as well (none of them worked)

1)

.MarkerPopUp
{
    height: 300px;
    width: 300px;
}

2)

.MarkerPopUp
{
    height: 300px;
    width: 300px;
}

   .MarkerContext
    {
        height: 300px;
        width: 300px;
    }

3)

.MarkerContext
{
    height: 300px;
    width: 300px;
}

This also will not work:

document.getElementById('MarkerPopUp')parentNode.style.overflow = '';

or this

document.getElementById('MarkerPopUp').parentNode.parentNode.style.overflow = '';

I am pretty much going through every thread I can find and trying everything. Just to limit a few things out (though there may be another issue)

解决方案

It may be that when the html is passed into the map api and parsed out that it doesn't have access to your stylesheet delcarations. Try adding your width as inline style on MarkerPopUp.

<div class = "MarkerPopUp" style="width: 300px;"><div class = "MarkerContext">Text</div></div>

I know, I hate inline styles too, but it could solve your issue in this case.

这篇关于Google地图.InfoWindow设置高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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