开发者

Controlling the width of a Google Maps 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).

I found a reference to maxWidth in the API but I cannot figure out where to put this. A开发者_如何学Pythonny ideas?


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

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."


You can override the style of Google Maps.

/* Just use .gm-style-iw */ 
.gm-style-iw {
  width: 300px; 
  min-height: 150px;
}

Source: https://katz.co/resizing-infowindow/


you can add div at first like this:

<div style='width:300px;margin:0 0 20px 20px;height:90px;'>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜