【发布时间】:2014-11-04 06:40:24
【问题描述】:
我尝试将 WMS 加载到我的地图中,如下所示:
<html>
<head><title>OpenLayers WMS test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script>
function init() {
var map = new OpenLayers.Map("maparea");
var wms = new OpenLayers.Layer.WMS("TIRIS", "https://gis.tirol.gv.at/arcgis/services/Service_Public/oph05_wms/MapServer/WMSServer",
{format: 'image/jpeg',
bbox: '10.07,46,13.03,47.735',
layers: 'Orthophoto_Tirol_05m',
width: 256,
height: 256},
{projection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
maxExtent: new OpenLayers.Bounds(10.07,46,13.03,47.735)});
map.addLayer(wms);
map.zoomToMaxExtent();
alert("Request string: " + wms.getFullRequestString());
}
</script>
</head>
<body onload="init()">
<h1>WMS Test</h1>
<div id="maparea"></div>
</body>
</html>
我在 chrome 控制台中没有收到任何错误,因此不知道从这里去哪里.. 如果我从网络选项卡打开链接(例如:https://gis.tirol.gv.at/arcgis/services/Service_Public/oph05_wms/MapServer/WMSServer?FORMAT=image%2Fjpeg&BBOX=11.55578125,46.864296875,11.558671875,46.8671875&LAYERS=Orthophoto_Tirol_05m&WIDTH=256&HEIGHT=256&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326),我会看到一个空白屏幕..
这是一个活生生的例子:http://gimoya.bplaced.net/WMS_test.html
提前感谢您的任何指点!
【问题讨论】:
-
工作示例受用户名和密码保护,因此难以调试。如果您可以通过网络选项卡从中获取有效的 wms 网址,那将有所帮助(假设您被允许)。
-
@JohnBarça,抱歉,我将 html 放到了我的 ftp 上的可访问目录中!对于您的第二个问题:我认为我从网络标签发布的内容就是您要的,不是吗?
-
通常您不会在 OpenLayers.Layer.WMS 中配置 BBOX、宽度和高度等内容。最小值是层名称、URL 和
layers(通常)。见这里:查看源:dev.openlayers.org/examples/lite.html. -
谢谢 - 我明白了!实际上,不需要几个参数。然而,正确的图层名称至关重要!
标签: openlayers wms