14

I have need to change width and height of google maps infoWindow and I saw this topic Google Map .InfoWindow Set Height and Width. I found that the solutions from it doesn't work. Even standart infoWindow = new google.maps.InfoWindow({maxWidth: '50px'}) isn't going to work.

So what is a solution? How to change width and height of infoWindow?

Community
  • 1
  • 1
Alexandre
  • 13,030
  • 35
  • 114
  • 173
  • 50 px is too small. See replies to this question: http://stackoverflow.com/questions/12102285/resize-the-infowindow-box-google-maps-api-v3 – Marcelo Aug 24 '12 at 19:09

7 Answers7

24

I always use a div inside the infowindow and it works best for me. Then you just set the size of the div via css.

Here is a link. :

Google Maps API v3: InfoWindow not sizing correctly

Community
  • 1
  • 1
Bill Blankenship
  • 3,316
  • 6
  • 43
  • 73
  • 1
    Just to let you know, this is the better answer and should have been treated as such. Add a div inside the infowindow object, i.e. var InfoWindow = new google.maps.InfoWindow({ content: "DIV HERE" }); –  Jul 23 '13 at 16:30
17

This works for me:

new google.maps.InfoWindow({ maxWidth: 320 });

Remove the ' ' and the px specifier and I believe it will work for you too.

Loudenvier
  • 8,362
  • 6
  • 45
  • 66
9

The GoogleMaps-API generates the class "gm-style-iw" around the InfoWindow. So you can simply change the size by CSS, without the need of extra markup:

var infowindow = new google.maps.InfoWindow({
    content: contentString
});


.gm-style-iw {
    height: 100px;
    width: 300px;
}
Jai Chauhan
  • 4,035
  • 3
  • 36
  • 62
Volker Andres
  • 849
  • 14
  • 32
3

I have added and it is working

var infowindow = new google.maps.InfoWindow({
content:'<div style="width:200px; height:100px">Some text</div>'
});
FosAvance
  • 2,363
  • 9
  • 36
  • 52
2

I know this is an old question but I would like to add a responsive solution. This will adapt nicely on small devices.

@media (max-width: 413px) {
// Set gm container to screen width leaving 20px pad on each side
  .gm-style-iw {
    width: calc(100vw - 40px)!important;
    min-width: unset!important;
    max-width: unset!important;
  }

  // Next is the container Div that you create on your infoWindow function
  // on google example var contentString = '<div id="content">'+

  .your-main-container-class {
    width: calc(100vw - 80px);
    padding: 8px 0;
    margin: auto;
  }
}

Then for bigger screens just set your width as google suggest

.your-main-container-class{
  width: 316px; // Your desire width
  padding: 8px 0 8px 8px; // Play with padding if you have a custom close button
}
ryangus
  • 679
  • 3
  • 8
  • 22
1
infowindow = new google.maps.InfoWindow({
    content: "",
    maxWidth: 200 ,
    maxHeight: 400
});
Tasos K.
  • 7,979
  • 7
  • 39
  • 63
0

I found that unless I forced the style with !important, it didn't work. So:

.gm-style-iw {
    height: 100px;
    width: 300px !important;
}
dcolumbus
  • 9,596
  • 26
  • 100
  • 165