This works to avoid Basemap layers such as Google Maps and overlays such as WMS to appear in the GeoExt Legend Panel:

var legendPanel = new GeoExt.LegendPanel({
    border: false,
    filter: function(record){
        if(!(record.getLayer().isBaseLayer) && (record.getLayer() instanceof OpenLayers.Layer.WMS)){
        return true;
    } });

The problem is that I need to filter (ie. no display) layers with names having "beam" in their names, I tried with no success this:

return record.getLayer().displayInLayerSwitcher == false && record.getLayer().name == '%beam%';
return record.getLayer().displayInLayerSwitcher == false &&
record.get("layer").name.indexOf("%beam%") == -1;
return record.get("layer").name.indexOf("%beam%") == -1;
  • 1
    Why did you surround the keyword with % in the first place? – kryger Jun 1 '15 at 12:44

Just remove the "%". Use

return record.getLayer().name.indexOf("beam") == -1;

instead of

return record.getLayer().name.indexOf("%beam%") == -1;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.