Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Openlayers WMS问题_Openlayers_Wms - Fatal编程技术网

Openlayers WMS问题

Openlayers WMS问题,openlayers,wms,Openlayers,Wms,我尝试将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> <sc

我尝试将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>

OpenLayers WMS测试
函数init(){
var map=newopenlayers.map(“maparea”);
var wms=新的OpenLayers.Layer.wms(“TIRIS”https://gis.tirol.gv.at/arcgis/services/Service_Public/oph05_wms/MapServer/WMSServer",
{格式:'image/jpeg',
bbox:'10.07,46,13.03,47.735',
图层:“正射照片”Tirol\u 05m“,
宽度:256,
高度:256},
{projection:new OpenLayers.projection(“EPSG:4326”),
单位:“m”,
maxExtent:newOpenLayers.Bounds(10.07,46,13.03,47.735)};
地图添加层(wms);
zoomToMaxExtent();
警报(“请求字符串:+wms.getFullRequestString());
}
WMS试验
我在chrome控制台中没有发现任何错误,因此不知道从这里可以走到哪里。。 如果我从网络选项卡(如:)打开链接,我会看到一个空白屏幕

下面是一个活生生的例子:


提前感谢您的指点

为了记录在案,我将在这里发布工作代码(感谢评论员!):


OpenLayers TIRIS layer=图像WMS测试
函数init(){
变量选项={
归属:{
标题:“由OSGeo提供”,
href:“http://www.osgeo.org/"
}
};
var map=newopenlayers.map(“maparea”);
var wms=new OpenLayers.Layer.wms(“TIRIS Orthofoto”https://gis.tirol.gv.at/arcgis/services/Service_Public/oph05_wms/MapServer/WMSServer",
{格式:'image/jpeg',
bbox:'1120600.9234869993453925879594.41115100029855971453307.414027000007893156067102.8815350001677871',
图层:'图像'},
{projection:new OpenLayers.projection(“EPSG:3857”),
maxExtent:new OpenLayers.Bounds(1120600.9234869993453925879594.41115100029855971453307.414027000007893156067102.8815350001677871)}
);
地图添加层(wms);
zoomToMaxExtent();
警报(“请求字符串:+wms.getFullRequestString());
}
WMS试验

工作示例是用户名和密码保护,这使得调试很困难。如果你可以通过网络标签从中获取一个工作的wms url,这会有所帮助(假设你被允许)。@JohnBarça,对不起,我把html放在ftp上的一个可访问目录中了!关于你的第二个问题:我认为我在“网络”选项卡上发布的内容是你想要的,不是吗?通常你不会在OpenLayers.Layer.WMS中设置诸如BBOX、宽度和高度之类的内容。最小值是层名称、URL和
(通常)。查看此处:查看来源:。谢谢-我知道了!事实上,不需要几个参数。但是,正确的图层名称至关重要!
<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>