2017-02-15 50 views
0
我目前使用原子與實時預覽擴展,它準確地顯示我的網頁是什麼 應該樣子

。也就是說,當我去實際的網站時,我只看到標題,而不是地圖。不知道發生了什麼事。我試過CTRL-F5並重新加載頁面沒有任何效果。這是我得到的。單張地圖出現在編輯器中,但不能在現場

的index.html

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Map Prototype</title> 
    <link rel="stylesheet" href="css/index.css" /> 
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> 
    <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/sandstone/bootstrap.min.css" rel="stylesheet" integrity="sha384-G3G7OsJCbOk1USkOY4RfeX1z27YaWrZ1YuaQ5tbuawed9IoreRDpWpTkZLXQfPm3" crossorigin="anonymous"> 
    <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> 
    </head> 

    <body> 
    <nav class="navbar navbar-default navbar-fixed-top"> 
     <div class="container"> 
     <div class="navbar-header"> 
      <button type="button" class="navbar-toggle collapse" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">...</button> 
      <a class="navbar-brand" href="index.html">Map Demo</a> 
     </div> 
     <div id="navbar" class="navbar-collapse collapse"> 
      <ul class="nav navbar-nav"> 
      <li class="active"><a href="index.html">Home</a></li> 
      <li><a href="http://vietnamwarstories.indiana.edu/" target="_blank">Website</a></li> 
      <li><a href="http://vietnamwarstories.indiana.edu/contact/" target="_blank">Contact</a></li> 
      </ul> 
      <ul class="nav navbar-nav navbar-right"></ul> 
     </div> 
    </nav> 

    <div id="map-container"> 
     <div id="map"></div> 
    </div> 

    <script src="js/map.js"></script> 
    </body> 
</html> 

index.css

html, body { 
    padding: 0; 
    margin: 0; 
} 

#map-container { 
    height: 100%; 
    width: 100%; 
} 

#map { 
    width: 100%; 
    height: 100%; 
} 

map.js

var map = L.map ('map', { center: [16.056, 100.745], zoom: 6 }); 

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { 
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' 
}).addTo(map); 
+0

刪除#地圖容器和#map設置爲一個固定的大小(寬度:960像素; 高度:500像素;)來代替,和它的工作...但最好我想爲大小可伸縮。 – Vigilant

回答

1

僅通過刪除#MA固定它p-container div並將html和body設置爲100%,並映射到100%。

html, body { 
    padding: 0; 
    margin: 0; 
    height: 100%; 
} 

#map { 
    height: 100%; 
} 
相關問題