Is there a way to get the type of all the layers in an OpenLayer maps object? What I am trying to do is iterate over all the layers in my OpenLayers map object and populate a dropdown list with the names of only the vector layers. All my vector layers come from a remote GeoServer and are WFS.
Here is the code I currently have that gets the names of the layers and populates a dropdown with the names. This code works fine;
function listLayers() {
var mLayers = map.layers; //set a variable to the layers array in the map object
document.getElementById("drpLayers").options.length = 0; // clear any existing options from the dropdown list
for (var a = 0; a < mLayers.length; a++) { //loop through the map layers array
var opt = document.createElement("option");//create an option object in the dropdown
opt.text = mLayers[a].name; //add the name of the layer for this dropdown list option to the text attribute of the option object
opt.value = mLayers[a].name; //add the name of the layer for this dropdown list option to the value attribute of the option object
document.getElementById("drpLayers").options.add(opt); //add the option object to the dropdown list
};
I thought I could just modify this code to something like this:
opt.text = mLayers[a].type
or perhaps this:
opt.text = mLayers[a].class
but neither way works. When I look at the OpenLayers documentation I cannot find a layer property that describes the layer type. Any suggestions would be appreciated!