jeudi 15 janvier 2015

Excluding layer from GoeExt 2 Legend Panel


I'm trying to exclude some legend in GeoExt.panel.Legend.


I've created a vector layer named 'City Extent' via a function but I want the legend to be removed in the list of legends in my legend panel.


The 'filter' option doesn't seem to work


Here's my vector layer for City Extent



city_ext = new OpenLayers.Layer.Vector("City Extent", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.WFS({
url: geoserverURL,
version: "1.1.0",
featureType: "gadm2",
featureNS: "http://ift.tt/1IAEmHR",
srsName: "EPSG:900913"
}),
filter: new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.AND,
filters: [
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "id_2", // city
value: params_2
}),
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "id_1", // province
value: params_1
}),
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "id_0", // country
value: params_0
})
]
}),
eventListeners: {
'loadend': function(evt) {
map.zoomToExtent(city_ext.getDataExtent());
}
}
});


Here's my GeoExt Legend Panel



var legendPanel = Ext.create('GeoExt.panel.Legend', {
defaults: {
labelCls: 'mylabel',
style: 'padding:5px'
},
bodyStyle: 'padding:5px',
width: 250,
autoScroll: true,
layerStore: mapPanel.layers,
// dynamic: false,
loader: {
filter: function(record) {
return record.get("layer").name.indexOf("City Extent") == -1
}
}
});


Could someone point to me the proper way to exclude/remove the legend?





Aucun commentaire:

Enregistrer un commentaire