我正在尝试将Openlayers与ASP MVC3集成,使用Geoserver作为学习过程但遇到了这个奇怪的问题。加载视图时,地图画布将显示为空白,并带有默认缩放控件。只有当我按下放大按钮时才会显示地图。我原本以为它与ASP的Razor View有关,所以我把它复制到一个单独的HTML文件但问题仍然存在。有什么建议吗?
<html>
<head>
<script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript">
function init() {
var bounds = new OpenLayers.Bounds(
-124.848974, 45.543541,
-116.91558, 49.002494);
var options = {
maxExtent: bounds,
maxResolution: 0.0309898203125,
projection: "EPSG:4326",
units: 'degrees'
};
var map = new OpenLayers.Map('map', options);
var wms = new OpenLayers.Layer.WMS("Washington County Map", "http://localhost:8080/geoserver/tiger/wms",
{
layers: 'tiger:county10',
format: 'image/png',
visibility: true,
isBaseLayer: true,
});
map.addLayer(wms);
map.zoomToExtend(bounds);
};
</script>
</head>
<body onload="init()">
<h2>Test</h2>
<p>
To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
</p>
<div id="map" style="width:800px; height:500px;" />
</body>
</html>
答案 0 :(得分:0)
您是否检查了缩放级别的Geoserver设置?您可以设置显示每个地图图层的最小和最大比例。