title: Setting full screen leaflet.js map using bootstrap
body: <p>I'm working in a template based on these examples:</p>
  
  <p><a href="http://getbootstrap.com/examples/dashboard/" rel="nofollow">http://getbootstrap.com/examples/dashboard/</a></p>
  
  <p><a href="http://leafletjs.com/examples/choropleth.html" rel="nofollow">http://leafletjs.com/examples/choropleth.html</a></p>
  
  <p>And I just want to have a full size leaflet map.
  However, I can't get it to work.</p>
  
  <p>This is my <strong>index.html</strong> file:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;html lang="en"&gt;
          &lt;head&gt;
              &lt;meta charset="utf-8"&gt;
              &lt;title&gt;NY Noise Map&lt;/title&gt;
              &lt;script src="http://code.jquery.com/jquery-2.1.0.min.js"&gt;&lt;/script&gt;
              &lt;script src="http://d3js.org/d3.v3.min.js" charset="utf-8"&gt;&lt;/script&gt; 
              &lt;!-- ####Leaflet#### --&gt;
              &lt;script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"&gt;&lt;/script&gt;
              &lt;link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" /&gt;
              &lt;!-- ################ --&gt;
              &lt;!-- ####Bootstrap### --&gt;
              &lt;script src="bootstrap-3.3.6-dist/js/bootstrap.min.js"&gt;&lt;/script&gt;
              &lt;link rel="stylesheet" href="bootstrap-3.3.6-dist/css/bootstrap.min.css" /&gt;
              &lt;!-- ################ --&gt;
              &lt;!-- #####Custom##### --&gt;
              &lt;script src="Scripts/map.js"&gt;&lt;/script&gt;
              &lt;link rel="stylesheet" href="CSS/dashboard.css" /&gt;
              &lt;!-- ################ --&gt;
          &lt;/head&gt;
          &lt;body&gt;
              &lt;!-- Top bar --&gt;
              &lt;nav class="navbar navbar-inverse navbar-fixed-top"&gt;
                  &lt;div class="container-fluid"&gt;
                      &lt;div class="navbar-header"&gt;
                          &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"&gt;
                              &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
                              &lt;span class="icon-bar"&gt;&lt;/span&gt;
                              &lt;span class="icon-bar"&gt;&lt;/span&gt;
                              &lt;span class="icon-bar"&gt;&lt;/span&gt;
                          &lt;/button&gt;
                          &lt;a class="navbar-brand" href="#"&gt;NY Noise Map&lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/nav&gt;
  
              &lt;!-- Content --&gt;
              &lt;div class="container-fluid"&gt;
                  &lt;!-- Right Panel --&gt;
                  &lt;div class="row"&gt;
                      &lt;div class="col-sm-3 col-md-2 sidebar"&gt;&lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;!-- Main Content --&gt;
                  &lt;div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"&gt;
                      &lt;h1&gt;NYC 311 Noise Complaints&lt;/h1&gt;
                      &lt;div id="map"&gt;&lt;/div&gt;        
                  &lt;/div&gt;
              &lt;/div&gt;
  
  
          &lt;/body&gt;
          &lt;script type="text/javascript"&gt;
  
              // Map creation
              createMap();
          &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is the <strong>dashboard.css</strong> file:</p>
  
  <pre><code> /*
   * Base structure
   */
  
  html, body, #container {
    height: 100%;
    overflow: hidden;
    width: 100%;
  }
  
  /* Move down content because we have a fixed navbar that is 50px tall */
  body {
    padding-top: 50px;
  }
  
  
  /*
   * Sidebar
   */
  
  .sidebar {
    float: left;
    height: 100%;
    max-width: 100%;
  }
  
  
  @media (min-width: 768px) {
    .sidebar {
      position: fixed;
      top: 51px;
      bottom: 0;
      left: 0;
      z-index: 1000;
      display: block;
      padding: 20px;
      overflow-x: hidden;
      overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
      background-color: #f5f5f5;
      border-right: 1px solid #eee;
    }
  }
  
  
  /*
   * Main content
   */
  
  .main {
    height: 100%;
    width: 100%;
    padding: 20px;
  }
  @media (min-width: 768px) {
    .main {
      padding-right: 40px;
      padding-left: 40px;
    }
  }
  .main .page-header {
    margin-top: 0;
  }
  </code></pre>
  
  <p>And this is the <strong>map.js</strong> file:</p>
  
  <pre><code>/* Map definition */
  
  //---- Map creation
  
  // Map size
  var width = 1000,
      height = 1000,
      active = d3.select(null);
  
  // Map reference
  var map;
  
  // Geojson of the neighborhoods reference
  var geojson;
  
  // ---- Map Creation
  // Creates a map inside div id="map"
  function createMap()
  {               
      // Set map wrapper size
      d3.select('#map')
        .style('width', width + 'px')
        .style('height', height + 'px');
  
      // Create Leftlet map and center it in the desired position
      // with the desirable zoom level
      map = L.map('map').setView([40.658528, -73.952551], 10);
  
      // Load a tile layer  
      L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', 
      { 
          attribution: 'Map data &amp;copy; &lt;a href="http://openstreetmap.org"&gt;OpenStreetMap&lt;/a&gt;',
          maxZoom: 18, 
          minZoom: 10
      }).addTo(map);
  }
  </code></pre>
  
  <p>If I comment this line:</p>
  
  <pre><code>// Set map wrapper size
  d3.select('#map')
    .style('width', width + 'px')
    .style('height', height + 'px');
  </code></pre>
  
  <p>I can't see any map on the screen. It doesn't matter if I set:</p>
  
  <pre><code>#map {
      height: 100px;
      width: 100px;
  }
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>#map {
      height: 100%;
      width: 100%;
  }
  </code></pre>
  
  <p>On the css file. I'm wondering what's wrong.</p>