首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Openlayers发行

Openlayers发行
EN

Stack Overflow用户
提问于 2014-09-30 14:37:35
回答 1查看 823关注 0票数 0

我试图将WMS加载到我的地图中,如下所示:

代码语言:javascript
复制
<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>

我在镀铬控制台中没有错误,因此不知道从这里到哪里。如果我打开网络选项卡上的链接(如:05m&WIDTH=256&HEIGHT=256&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326),就会得到一个空白的屏幕。

下面是一个活生生的例子:test.html

提前感谢您的指点!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-03 22:40:24

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

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26123526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档