[OpenLayers-Users] getCapabilities

Arnd Wippermann arnd.wippermann at web.de
Tue Jun 11 12:11:06 PDT 2013


Hi,
 
you have missed one level.
 
var GetCapabilities = format.read(xml);
var capability = GetCapabilities.capability;
 
and you need a proxy script to get the response from a remote server.
 
that should work:
 
OpenLayers.ProxyHost = "proxy.cgi?url=";
 
function init()
{
    var request = OpenLayers.Request.GET({
            url:
"http://geodaten.bayern.de/ogc/ogc_dop200_oa.cgi?service=WMS&request=GetCapa
bilities&version=1.1.1",
            success: function(response){
                var xml = request.responseXML;
                var format = new
OpenLayers.Format.WMSCapabilities({version:"1.1.1"});
                var GetCapabilities = format.read(xml);
                var capability = GetCapabilities.capability;
 
                var WMS_Title      = GetCapabilities.service.title;
                var WMS_Abstract   = GetCapabilities.service.abstract;
                var OnlineResource =
GetCapabilities.capability.request.getmap.href;
 
                var Msg = "";
 
                Msg += WMS_Title + "\n\n";
                Msg += WMS_Abstract + "\n\n";
                Msg += OnlineResource + "\n\n";
 
                for (var i=0; i < capability.layers.length; i++) {
                    layer = capability.layers[i];
                    Msg += layer.title + " :: " + layer.name + "\n";
                }
                alert(Msg);
 
            }
    });
}
 
init();
 
Arnd

 

----------------------------------------------------------------------------
----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Helmut
Seidel M.A.
Gesendet: Dienstag, 11. Juni 2013 17:25
An: 'Bart van den Eijnden'
Cc: openlayers-users at lists.osgeo.org
Betreff: Re: [OpenLayers-Users] getCapabilities


Hello again,

 

I've changed the code to someting like:

 

function init(){

var request = OpenLayers.Request.GET({

                url:
"http://geodaten.bayern.de/ogc/ogc_dop200_oa.cgi?service=WMS&request=GetCapa
bilities&version=1.1.1",

                 success: function(response){

                                var format = new
OpenLayers.Format.WMSCapabilities();

 

                                var xml = request.responseXML;

                               var capabilities = format.read(xml);

                                                               

                               for (var i=0; i < capabilities.layers.length;
i++) {

                                               layer =
capabilities.layers[i];

 

 
alert(layer.name);

                               }

                }

                });

}

 

But that does not really improve things, so I guess that's not what you've
meant- sorry I'm really new to OpenLayers.

 

Thanks again

 

Helmut

 



More information about the Users mailing list