I ran into this same problem today and eventually found this at the official Google Maps Javascript API V3 Reference:
Developers should trigger this event on the map when the div changes
size:google.maps.event.trigger(map, 'resize')
.
As display:none
is equivalent to leaving the <div>
with size 0, changing it to display:block
becomes in fact a change of size, making therefore necessary to trigger the map resize event.
Worked like a charm for me.
UPDATE 2018-05-22
With a new renderer release in version 3.32 of Maps JavaScript API the resize event is no longer a part of Map
class.
The documentation states
When the map is resized, the map center is fixed
The full-screen control now preserves center.
There is no longer any need to trigger the resize event manually.
source: https://developers.google.com/maps/documentation/javascript/new-renderer
google.maps.event.trigger(map, "resize");
doesn’t have any effect starting from version 3.32