为什么这个WMS层没有出现在openlayers中?

为什么这个WMS层没有出现在openlayers中?,openlayers,arcgis,wms,Openlayers,Arcgis,Wms,我试图显示一个来自已发布的ArcGIS地图服务的WMS图层,我得到的只是粉红色的瓷砖。有人能帮我纠正代码的错误吗?当我去美国的时候,我得到的只是“破碎的图像粉色瓷砖”。。。没有出现任何WMS层 <html> <head> <title>Karta</title> <link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css">

我试图显示一个来自已发布的ArcGIS地图服务的WMS图层,我得到的只是粉红色的瓷砖。有人能帮我纠正代码的错误吗?当我去美国的时候,我得到的只是“破碎的图像粉色瓷砖”。。。没有出现任何WMS层

<html>
<head>
    <title>Karta</title>
    <link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css">
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script  type="text/javascript">
    function inicializacija(){
        var options = {
            projection: new OpenLayers.Projection("EPSG:4326"),
            units: "m",
            numZoomLevels: 18,
            maxResolution: 156543.0339,
            maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)
            };
         var map = new OpenLayers.Map("map-id", options);
         //var osm = new OpenLayers.Layer.OSM("Open Street Map");
         //var wms = new OpenLayers.Layer.MapServer( "World Map", "http://localhost/cgi-bin/mapserv.exe", {layers: 'countries',map: '/ms4w/Apache/htdocs/MapFile06_wms.map', srs: 'EPSG:4326'} );

        //map.addLayers([osm,wms]);

        layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
            "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?request=GetCapabilities&service=WMS", {layers: "States"} );
        map.addLayer(layer);

        map.addControl(new OpenLayers.Control.LayerSwitcher());
        map.addControl(new OpenLayers.Control.MousePosition());


        map.zoomToExtent(new OpenLayers.Bounds(1490000, 5600000,1850000, 5900000));
    }
</script>
    <style>
        #map-id {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body onload= 'inicializacija()'>
    <h1>Primer prekrivanja slojev in izbire podlag</h1>
    <div id="map-id"></div>
</body>
</html>

卡尔塔
功能inicializacija(){
变量选项={
投影:新OpenLayers.projection(“EPSG:4326”),
单位:“m”,
numZoomLevels:18,
最大分辨率:156543.0339,
maxExtent:new OpenLayers.Bounds(-20037508.34,-20037508.3420037508.3420037508.34)
};
var map=new OpenLayers.map(“map id”,选项);
//var osm=新的OpenLayers.Layer.osm(“开放街道地图”);
//var wms=new OpenLayers.Layer.MapServer(“世界地图”)http://localhost/cgi-bin/mapserv.exe“,{layers:'countries',map:'/ms4w/Apache/htdocs/MapFile06_wms.map',srs:'EPSG:4326'});
//map.addLayers([osm,wms]);
层=新的OpenLayers.layer.WMS(“OpenLayers WMS”,
"http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?request=GetCapabilities&service=WMS“,{层:“状态”});
map.addLayer(层);
addControl(新的OpenLayers.Control.LayerSwitcher());
addControl(新的OpenLayers.Control.MousePosition());
zoomToExtent(新的OpenLayers.Bounds(14900005600001850005900000));
}
#地图id{
宽度:100%;
身高:100%;
}
izbire podlag中的引物prekrivanja slojev

图像显示为红色,因为请求没有生成有效的地图图像

以下是调试此类问题的方法:

  • 在FireFox或Chrome中打开页面
  • 然后将其中一个红色图像保存到磁盘
  • 在文本编辑器中打开保存的文件
现在,看起来您不是在请求映像,而是在请求服务器的功能

您可能已经将服务器URL粘贴到代码中,但是您已经粘贴了请求服务器可以做什么以及它支持什么的URL

因此,只需从URL中删除此部分:
request=GetCapabilities

这样它就变成:
http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?service=WMS

保存HTML,然后刷新

好的,我们现在确实在请求图像,但你仍然没有得到任何东西

所以,也要这样做。保存一个红色图像,然后查看其中的内容

这一次里面有一条错误消息:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1">
  <ServiceException code="LayerNotDefined">
Parameter 'layer(s)' contains unacceptable value: States
  </ServiceException>
</ServiceExceptionReport>

参数“层”包含不可接受的值:状态
看起来您正在请求一个名为
States
的层,但该层不存在


只要提供一个有效的层,你就应该这样做。看起来服务器上有两层,分别称为“1”和“2”。当你将其设置为图层时,红色图像消失了,但它们似乎没有包含任何有趣的内容,但这是我无法帮助你解决的另一个问题,除非我得到更多信息。

当你看美国时,它应该包含一些有趣的内容。看看这里:你可以在这里查看图层应该包含的内容:执行你在帖子中所说的,看起来什么都没有显示,即使我放大到美国。如果我将WMS图层添加到ArcGIS.com地图中,它可以理解范围,但不显示任何数据…想法?可能您没有指定正确的坐标投影,所有内容都会显示在视图之外。指定EPSG:4326,即WGS84,但用于设置范围的坐标和缩放的框似乎输入为EPSG:900913。你知道我在说什么吗?