我尝试将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
提前感谢任何指针!
答案 0 :(得分:0)
为了记录,我将在这里发布工作代码(感谢评论员!):
<html>
<head><title>OpenLayers TIRIS layer=Image 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 options = {
attribution: {
title: "Provided by OSGeo",
href: "http://www.osgeo.org/"
}
};
var map = new OpenLayers.Map("maparea");
var wms = new OpenLayers.Layer.WMS("TIRIS Orthofoto", "https://gis.tirol.gv.at/arcgis/services/Service_Public/oph05_wms/MapServer/WMSServer",
{format: 'image/jpeg',
bbox: '1120600.9234869999345392,5879594.4111510002985597,1453307.4140270000789315,6067102.8815350001677871',
layers: 'Image'},
{projection: new OpenLayers.Projection("EPSG:3857"),
maxExtent: new OpenLayers.Bounds(1120600.9234869999345392,5879594.4111510002985597,1453307.4140270000789315,6067102.8815350001677871)}
);
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>