Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display a Google Map in a fixed position div?
    primarykey
    data
    text
    <p>I'm trying to put a fixed position map on my webpage. I put the a snippet of index.html file below. I have a <code>div</code> with <code>id="map-mini"</code> under a <code>div</code> with <code>class="map-container"</code>.</p> <p>I defined the position of the map-container as fixed(the post.css file is given at the end of the file).</p> <p>I initialize the map with function given in post.js. However, when I refresh my webpage, the map is not initialized. </p> <p>Do you have a suggestion that can solve my problem? </p> <p>jsfiddle for the given code is as follows: <a href="http://jsfiddle.net/N2V8S/2/" rel="nofollow">http://jsfiddle.net/N2V8S/2/</a></p> <p>Regards.</p> <p>index.html:</p> <pre><code>&lt;div class="container-fluid"&gt; &lt;div class="row-fluid"&gt; &lt;div class="span2"&gt; &lt;div class="map-container"&gt; &lt;div id="map-mini"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="span8"&gt; &lt;div id="post"&gt; &lt;div class="body"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p></p> <p>post.js:</p> <pre><code>$(document).ready(function() { var map_id = '#map-mini'; var lat = 41.04207384890103; var lng = 29.0972900390625; var zoom = 11; var myOptions = { zoom : zoom, center : new google.maps.LatLng(lat, lng), mapTypeId : google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map-mini"), myOptions); }); </code></pre> <p>post.css:</p> <pre><code>.map-container{ position: fixed; border: solid gray 1px; width: 17%; height: 80%; top: 50px; left: 0.5%; } </code></pre>
    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.
 

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