2017-02-15 64 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%; 
}