我正在尝试展示一个已发布的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>