[OpenLayers-Dev] wms capabilities

Aditya Kumar paglacontact at yahoo.com
Wed Jan 5 04:40:42 EST 2011


Dear Users,
     When I am trying to call any external url its not showing the data and
when we are trying to read the xml file it is showing the error as the
attached file.Can anyone help please?


http://osgeo-org.1803224.n2.nabble.com/file/n5891454/scren.bmp 








the code I am using for this is :
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>OpenLayers Example</title>
	<style type="text/css"><!-- DIV {margin:0px;} --></style>
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css"
/>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">
 


   
        function init(){ 




		   var map = new OpenLayers.Map('map'); 

            var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "http://vmap0.tiles.osgeo.org/wms/vmap0?", 
					{layers: 'basic', format: 'image/gif'} );

          
              
var request = OpenLayers.Request.GET(
         {url:
"http://disc1.sci.gsfc.nasa.gov/daac-bin/wms_airsnrt?service=wms&version=1.1.1&request=getcapabilities",
            success: function(response){
			
                            var format = new OpenLayers.Format.XML();
                            var xml = format.read(response.responseText);
						alert(response.responseText);
                          
                          var text = format.write(xml);
						  alert (text); 

    var CAPformat = new OpenLayers.Format.WMSCapabilities.v1_1_1();
							var cap = CAPformat.read(xml);
							
                        
						 
                            for (var i=0; i<cap.capability.layers.length;
i++) {
                                layer = cap.capability.layers[i];
                              
							  alert(layer.name);
						var layers_array = new OpenLayers.Layer.WMS(layer.name, 
					
"http://disc1.sci.gsfc.nasa.gov/daac-bin/wms_airsnrt?service=wms&version=1.1.1&request=getcapabilities", 
						{'layers': layer.name, format: 'image/png'},{isBaseLayer:false}
						);
   
   
  map.addLayer(layers_array);}
  map.addLayers([ol_wms]);   
            map.addControl(new OpenLayers.Control.LayerSwitcher());
           map.setCenter(new OpenLayers.LonLat(77,23), 3);

							  
                         
                            
                        }
            })
   

           
        };
    </script>
  </head>
  <body onload="init()">
    <h1 id="title">OpenLayers Example</h1>
    <div id="tags"></div>
    <p id="shortdesc">
        Demonstrate a simple map with an overlay that includes layer
switching controls.
    </p>
    <div id="map" width: 900px; height:	500px; class="smallmap"></div>
    <div id="docs"></div>

  </body>
</html>







Aditya Kumar
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/wms-capabilities-tp5891454p5891454.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.


More information about the Dev mailing list