Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>for Google Maps v3, you need to trigger the resize event differently:</p> <pre><code>google.maps.event.trigger(map, "resize"); </code></pre> <p>See the documentation for the resize event (you'll need to search for the word 'resize'): <a href="http://code.google.com/apis/maps/documentation/v3/reference.html#event" rel="nofollow noreferrer">http://code.google.com/apis/maps/documentation/v3/reference.html#event</a></p> <hr> <p><strong>Update</strong> </p> <p>This answer has been here a long time, so a little demo might be worthwhile &amp; although it uses jQuery, there's no real need to do so.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() { var mapOptions = { zoom: 8, center: new google.maps.LatLng(-34.397, 150.644) }; var map = new google.maps.Map($("#map-canvas")[0], mapOptions); // listen for the window resize event &amp; trigger Google Maps to update too $(window).resize(function() { // (the 'map' here is the result of the created 'var map = ...' above) google.maps.event.trigger(map, "resize"); }); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>html, body { height: 100%; } #map-canvas { min-width: 200px; width: 50%; min-height: 200px; height: 80%; border: 1px solid blue; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;dummy=.js"&gt;&lt;/script&gt; Google Maps resize demo &lt;div id="map-canvas"&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <p><strong>UPDATE 2018-05-22</strong></p> <p>With a new renderer release in version 3.32 of Maps JavaScript API the resize event is no longer a part of <code>Map</code> class.</p> <p>The documentation states </p> <blockquote> <p>When the map is resized, the map center is fixed</p> <ul> <li><p>The full-screen control now preserves center.</p></li> <li><p><strong>There is no longer any need to trigger the resize event manually.</strong></p></li> </ul> </blockquote> <p>source: <a href="https://developers.google.com/maps/documentation/javascript/new-renderer" rel="nofollow noreferrer">https://developers.google.com/maps/documentation/javascript/new-renderer</a></p> <p><code>google.maps.event.trigger(map, "resize");</code> doesn't have any effect starting from version 3.32</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload