我正在尝试将地图添加到我的网页中。形状文件在 GeoServer 中上传/发布。发出请求时,网页中不会显示地图。以下是代码。
<html>
<head>
<script type="text/javascript" src="OpenLayers.js"></script>
<script type="text/javascript">
var map;
function init() {
map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://localhost:8080/geoserver/New_York_Roads/wms",
{ layers: 'basic' }
);
map.addLayers([wms]);
map.zoomToMaxExtent();
}
</script>
</head>
<body onload="init()">
<div id="map" style="width: 600px; height: 300px">
</div>
</body>
</html>