Hi,

You must install a proxy script to retrieve information from remote domains via 
an XMLHttpRequest.

http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#ProxyHost

Then you can use the class OpenLayers.Format.WMSCapabilities to parse the 
response like this:

var capabilitiesRequest = OpenLayers.Request.GET({
  url: 
"http://labs.metacarta.com/wms/vmap0?request=GetCapabilities&service=WMS";,
  success: parseWmsCapabilities,
  failure: function(response) {}
});

var parseWmsCapabilities = function(response) {
  var wmsParser = new OpenLayers.Format.WMSCapabilities();
  var wmsCapabilities = wmsParser.read(response.responseText);
  for(var i=0; i<wmsCapabilities.capability.layers.length; ++i) {               
 
    alert(wmsCapabilities.capability.layers[i].name);
  }
} 

Best regards,
Gabriel Nolasco
Hi all,
I want to get WMSGetCapabilites from server. The URL is
http://labs.metacarta.com/wms/vmap0?request=GetCapabilities&service=WMS and
works fine.

But when I "execute" the next code the request never ends or returns me a
empty response.

Anybody can help me clarifiying me how to get wms capabilities and later get
the available layer names?

Thanks in advance.

  <html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src='./js/ol/OpenLayers.js'></script>
        <script type="text/javascript">
            request = OpenLayers.Request.GET({
                url: "
http://labs.metacarta.com/wms/vmap0?request=GetCapabilities&service=WMS";,
                success: function(request){
                    alert(request.responseText);
                },
                failure: function(request){
                    alert('BOOOOOO!');
                }

            });
        </script>

    </head>
    <body>
        the body content
    </body>
</html>



      
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to