I'm using Apache Tomcat 7.0.72 & Geoserver v2.2 & php v5.3.5. i'm going to make a server side app with PHP that controls Accessing the layers that are published with Geoserver.In viewing the layers from the Geoserver i'm using Openlayers3.i want to have a list of layers that are published in Geoserver. what should i do??!
Why aren't you just using a WMS GetCapabilities request? OpenLayers has ol.format.WMSCapabilities
, so you can easily get a JSON from the available layers.
var xhr = new XMLHttpRequest();
xhr.open('GET', '/geoserver/wms?service=wms&request=GetCapabilities');
xhr.onload = function() {
var parser = new ol.format.WMSCapabilities();
var capabilities = parser.read(xhr.responseText);
var layers = capabilities.Capability.Layer.Layer;
/* List of layers is now in the `layers` array */
};