我有这个没有显示地图的Thymeleaf模板。它仅在我删除<!DOCTYPE HTML>
<!DOCTYPE HTML>
<html>
<head>
<title>OpenLayers 2 Example</title>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
map.zoomToMaxExtent();
</script>
</body>
</html>
答案 0 :(得分:0)
确保您的身体有尺寸,例如:通过添加以下css:
html, body: {
width: 100%;
height: 100%;
margin: 0;
}