[OpenLayers-Users] add layer name in dropdown box from geoserver
Phil Scadden
p.scadden at gns.cri.nz
Thu Feb 23 15:10:49 EST 2012
Issue WMS GetCapabilities eg
Ext.Ajax.request({
url: "adminproxy.jsp",
success: addWmsData,
params:{url: layerUrl +
"service=WMS&request=GetCapabilities&version=1.1.1"}
});
where the callback looks something like this:
function addWmsData(response){
wmsGetCapabilitiesDocument = response.responseXML;
wmsGetCapabilitiesParsed = new
OpenLayers.Format.WMSCapabilities.v1_1_1().read(wmsGetCapabilitiesDocument);
var layerData = [];
var tmp=-1;
for (i = 0; i <
wmsGetCapabilitiesParsed.capability.layers.length; i++) {
var layer =
wmsGetCapabilitiesParsed.capability.layers[i];
layerData[i] = [layer.name,
layer.title];
}
// now use the layerData array as a store for a combo box.
availableLayerStore.loadData(layerData);
}
The above is for using an Ext Store to an ext combo box, but you should
be able to use something similar for whatever your framework is.
Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
More information about the Users
mailing list