Rol*_*ndo 2 arcgis wms openlayers
我试图从已发布的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>
Run Code Online (Sandbox Code Playgroud)
图像显示为红色,因为请求未生成有效的地图图像.
这是你调试这个问题的方法:
现在,看起来您没有请求图像,但是您正在请求服务器的功能.
您可能已将服务器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>
Run Code Online (Sandbox Code Playgroud)
看起来您正在请求一个名为的图层States,但该图层不存在.
只需提供一个有效的图层即可完成.看起来服务器上有2层,称为"1"和"2".当你将它设置为图层时,红色图像消失了,但它们似乎没有包含任何有趣的东西,但这是我无法帮助你的另一个问题,除非我获得更多信息.
| 归档时间: |
|
| 查看次数: |
5691 次 |
| 最近记录: |