[OpenLayers-Users] How to get list of all Layers from a wms servoce?

Linde Ackermans roselinda.ackermans at ec.europa.eu
Tue May 26 05:17:53 EDT 2009


Hi,

An  example for WMSCapabilities  ( but I don't know how to expose all of the
properties, like srs, etc...)
Hope it is helpfull.

<!DOCTYPE html>
<html>
<head>
<title>Read WMS Capabilities</title>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script src="http://openlayers.org/api/2.8-rc3/OpenLayers.js"></script>
<!--
<script src="/openlayers/OpenLayers.js"></script>
-->

<script type="text/javascript">
    OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";

	var request = OpenLayers.Request.GET({
    url:
"http://your-server-url-path-to-a-WMS-service?request=getcapabilities&version=1.1.1",
    success: function(response) {
//    	alert(response.responseText);
        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];
        	alert(layer.name);
//        	alert(layer.title);
//        	alert(layer.llbbox);
//        	alert(layer.styles.length);
	        for (var j=0; j<layer.styles.length; j++) {
	        	alert(layer.styles[j].legend.href);
       			}
        	}
    	},
    failure: function(response) {
    	alert(response.status);
    	alert("GetCapabilities failed");
    	}
	});
</script>
</head>
</html>



Geo-rge wrote:
> 
> Hello list,
> 
> Does anybody have a good sample regarding WMSCapabilities,  
> WMSDescribeLayer and WMSGetFeatureInfo ? It would be very useful!
> 
> 

-- 
View this message in context: http://n2.nabble.com/How-to-get-a-list-of-all-layers-from-a-wms-service--tp2642660p2973649.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list