Acccording to the OpenLayers docs, cap in your case is just an array,
see the documentation for the 'read' method:

http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Format/WMSCapabilities-js.html


Alex



On Mon, Dec 27, 2010 at 4:23 AM, Aditya Kumar <[email protected]> wrote:
>
> Dear Users,
>   I am trying to get the wms get capabilties from the wms url using the
> following code.
>
>                        var request = OpenLayers.Request.GET(
>            {url:
> "http://www.geosignal.org/cgi-bin/wmsmap?version=1.1.1&service=WMS&request=GetCapabilities";,
>            success: function(response){
>                            var XMLformat = new OpenLayers.Format.XML();
>                            var xml = XMLformat.read(response.responseText);
>                            var CAPformat = new
> OpenLayers.Format.WMSCapabilities();
>                            var cap = CAPformat.read(xml);
>
>                            for (var i=0; i<cap.capability.layers.length;
> i++)
>                                                        {
>                                                        layer = 
> cap.capability.layers[i];
>
>                                            if(layer.name == 'OCG:WMS'){
>                                                layers_array[i] = new
> OpenLayers.Layer.WMS( layer.name,
>                                                "dir/wms.php",
>                                                {'layers': layer.name,
> isBaseLayer:true, format: "image/png", 'viewer': 'OpenLayers'}
>                                                );
>                                            }
>                                            else{
>                                                layers_array[i] = new
> OpenLayers.Layer.WMS( layer.name,
>                                                "dir/wms.php",
>                                                {'layers': layer.name,
> transparent: "true", format: "image/png", 'viewer': 'OpenLayers'}
>                                                );
>                                            }
>
>
>                                map.addLayer(layers_array[i]);
>                            }
>
>                        },
>                failure: function(response){
>                            alert(response.status);
>                            alert("GetCapabilities failed");
>                                }
>            });
>
> But i am getting one error
> "cap.capability is undefined".
> Please help me to solve this.
>
>
> Aditya Kumar
> --
> View this message in context: 
> http://osgeo-org.1803224.n2.nabble.com/wms-getfeature-info-tp5869202p5869202.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to