
Question:
There are several posts relating to this topic here but I've applied what seemed relevant on everything I read:
<strong>CSS</strong>
.infoWindow {
width: 90px;
height: 90px;
}
<strong>Create InfoWindow and assign to marker</strong>
var infowindow = new google.maps.InfoWindow({
content: '<div class="infoWindow">Test</div>',
maxWidth: 100
});
infowindow.open(map,test);
<strong>Result</strong>
<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/JYc5n.png" data-original="https://i.stack.imgur.com/JYc5n.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />
As you can see the InfoWindow appears at minimum size and no text is visible, this is also the case if I strip out the <div>
tag and all styling parameters and just try to display "Test".
<a href="http://rlcoaching.com/albaraka/" rel="nofollow">You can check the live site yourself here (hover over top right of screen to display map)</a>
<strong>Why does the InfoWindow insist on staying at minimum size?</strong>
<strong>EDIT: Turns out this problem only happens on a "reload", IE: when page is cached. Every time I clear the cache it works fine, but if I reload page without clearing cache it displays like in the picture above. Tried on Firefox & Chrome, OSX</strong>
Answer1:try this solution putting the content inside a variable.
var content='<div class="infoWindow">Test</div>';
var infowindow = new google.maps.InfoWindow({
content:content,
maxWidth: 100
});
in the past I had similar problem and this worked.
<strong>update</strong>
I have removed some options from Infowindow
according to <a href="https://developers.google.com/maps/documentation/javascript/infowindows#add" rel="nofollow">this</a> documentation.
The InfoWindowOptions object literal contains the following fields: <br /> 1)content <br /> 2)position <br /> 3)maxWidth
</blockquote> </blockquote><strong>update 2</strong>
set min-height
, min-width
css property to your .infoWindow
class
<strong>update 3</strong>
see <a href="https://stackoverflow.com/questions/19575796/force-google-infowindow-to-redraw-itself-or-refresh-its-content" rel="nofollow">this</a> stack question for your new problem