控制Google Maps InfoWindow的宽度 [英] Controlling the width of a Google Maps InfoWindow

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

问题描述

任何人都知道如何在Google Maps中设置InfoWindow的宽度? infowindow就像当你点击Google地图上的一个点时会弹出的泡泡一样。我可以通过CSS控制高度,但无法弄清楚如何改变宽度(我想要比默认infowindow更薄)。

Anyone know how to set the width of the InfoWindow in Google Maps? The infowindow is the cartoon like bubble that pops up when you click on a point in Google Maps. I can control the height via CSS but cannot figure out how to change the width (I want thinner than the default infowindow).

我在API中找到了maxWidth的引用但我无法弄清楚在哪里放置这个。任何想法?

I found a reference to maxWidth in the API but I cannot figure out where to put this. Any ideas?

推荐答案

对于API的v3, InfoWindowOptions.maxWidth 属性做你所要求的。 InfoWindow 构造函数接受一个 InfoWindowOptions 对象的可选参数。

For v3 of the API, the InfoWindowOptions.maxWidth property does what you're asking for. The InfoWindow constructor takes an optional argument of an InfoWindowOptions object.

var iw = new google.maps.InfoWindow({ content: some_text, maxWidth: 200 });

documentation 注意,只有在调用open之前设置值才会被考虑。要在更改内容时更改最大宽度,调用close,setOptions,然后打开。

The documentation notes that the "value is only considered if it is set before a call to open. To change the maximum width when changing content, call close, setOptions, and then open."

这篇关于控制Google Maps InfoWindow的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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