[Users] featureStore filter reload

Simone Dalmasso simone.dalmasso at gmail.com
Tue Nov 2 18:12:20 CET 2010


Hi, I've found the solution:
here follows my code that is the filter on the store:

*map.events.register('zoomend',this, function(){*
* **var extent = map.getExtent();*
* **featureStore.filterBy(function(record){*
* **return extent.containsLonLat(new
OpenLayers.LonLat(record.data.feature.geometry.x,record.data.feature.geometry.y));
*
* **}); *
* **});*
*
*
Many thanks.

2010/11/2 Simone Dalmasso <simone.dalmasso at gmail.com>

> With ratio and resFactor I can see a request on each zoom action but the
> list in my gris is always the same with all  objects.
> Being that my map starts at the full zoom and with all features displayed
> and I want that zooming in the gird reduce the number of names displayed. I
> should try to apply the filter only on the featureStore that fills the grid,
> so to avoid continuous requests to the server.
>
> Thanks for your explanation Andreas, now is more clear.
>
>
> 2010/11/2 Andreas Hocevar <ahocevar at opengeo.org>
>
>> Hi,
>>
>> there is no need to redraw the layer on zoomend. The reason why you don't
>> see changes is because the BBOX strategy won't reload features if you zoom
>> in, and has a buffer so it may be that you can also zoom out once before you
>> see changes.
>>
>> If you really want the strategy to reload on every zoom, and load it
>> exactly the features that match the visible match extent, you should
>> configure the strategy with
>>
>> ratio: 1,
>> resFactor: 1
>>
>> Regards,
>> Andreas.
>>
>> On Nov 2, 2010, at 15:23 , Simone Dalmasso wrote:
>>
>> > Seems that the proxy doesn't have the setFilter method.
>> > Actually the strategy is an excellent solution, but I need to trigger a
>> reload of the store on zoomend and moovend.
>> >
>> > To explain I pos my new code:
>> >
>> > var sites = new OpenLayers.Layer.Vector('Sites',{
>> >                               styleMap: styleMap,
>> >                               strategies: [/*new
>> OpenLayers.Strategy.Fixed(),*/new OpenLayers.Strategy.BBOX()],
>> >                               projection: new
>> OpenLayers.Projection("EPSG:4326"),
>> >                               protocol: new OpenLayers.Protocol.WFS({
>> >                                       version: "1.1.0",
>> >                                   srsName: "EPSG:4326",
>> >                                       url: '/geoserver/wfs/',
>> >                                       featureType: 'name',
>> >                                   featurePrefix: "prefix"
>> >                               })
>> >                       });
>> >
>> > map.events.register('zoomend',this, function(){
>> >                sites.redraw();
>> >       });
>> >
>> > var featureStore = new GeoExt.data.FeatureStore({
>> >           fields: [
>> >               {name: "name", type: "string"}
>> >           ],
>> >           layer: sites
>> >       });
>> >
>> > and more...
>> >
>> > With that I can't see changes in the grid.
>> >
>> > Thanks a lot for your help.
>> >
>> > Simone
>> >
>> > 2010/11/2 Andreas Hocevar <ahocevar at opengeo.org>
>> > Hi,
>> >
>> > try the following:
>> >
>> > featureStore.proxy.setFilter(your_new_filter);
>> > featureStore.reload();
>> >
>> > But note that you could also configure your vector layer with your
>> protocol and a BBOX strategy, and bind your featureStore to that layer by
>> configuring the store's layer property. This will make the BBOX strategy
>> take care of requesting features for the correct extent.
>> >
>> > Regards,
>> > Andreas.
>> >
>> > On Nov 2, 2010, at 14:24 , Simone Dalmasso wrote:
>> >
>> > > Hi list, I have an OL vector layer with a feature store linked. The
>> output of the store is in a grid, so I have the name of the features
>> selectable.
>> > > What I would like to do is to apply a spatial filter (BBOX) on the
>> store to have displayed in the grid only the features that are within the
>> BBOX. The update events for the store should be the 'zoomend' and the
>> 'moveend' events of the map.
>> > > I post some code:
>> > >
>> > > var featureStore = new GeoExt.data.FeatureStore({
>> > >           fields: [
>> > >               {name: "name", type: "string"}
>> > >           ],
>> > >           layer: map.getLayersByName('Sites')[0],
>> > >             featureFilter : new OpenLayers.Filter.Spatial({
>> > >               type : OpenLayers.Filter.Spatial.BBOX,
>> > >               value : map.getExtent()
>> > > });
>> > > var gridFeature = new Ext.grid.GridPanel({
>> > >               store: featureStore,
>> > >               sm: new GeoExt.grid.FeatureSelectionModel(),
>> > >               cm: new Ext.grid.ColumnModel([{header:'Name',dataIndex:
>> "name",id:'name'}]),
>> > >               autoExpandColumn : 'name'
>> > > });
>> > >
>> > > Then I wrote:
>> > > map.events.register('zoomend',this, function(){
>> > >             featureStore.reload();
>> > > });
>> > >
>> > > But in this way I get the this.proxy is null error from ext.js
>> > > I've also tried to re-bind the layer:
>> > > map.events.register('zoomend',this, function(){
>> > >     featureStore.unbind();
>> > >     featureStore.bind(map.getLayersByName('Sites')[0]);
>> > > });
>> > >  But I get record is undefined error from ext.js
>> > >
>> > > For both I still have all the features displayed in the grid.
>> > > Maybe I should destroy and recreate the entire gridPanel but is not
>> the right way to do that for me.
>> > > Can you help me?
>> > > Thanks
>> > > --
>> > > Simone Dalmasso
>> > > _______________________________________________
>> > > Users mailing list
>> > > Users at geoext.org
>> > > http://www.geoext.org/cgi-bin/mailman/listinfo/users
>> >
>> > --
>> > Andreas Hocevar
>> > OpenGeo - http://opengeo.org/
>> > Expert service straight from the developers.
>> >
>> >
>> >
>> >
>> > --
>> > Simone Dalmasso, Ing.
>> > ITHACA
>> > Information Technology for Humanitarian Assistance, Cooperation and
>> Action
>> > www.ithacaweb.org
>> > Via Pier Carlo Boggio 61 - 10138 Torino
>> > Tel: +39.011.1975.1854
>> > _______________________________________________
>> > Users mailing list
>> > Users at geoext.org
>> > http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>
>>
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>>
>
>
> --
> Simone Dalmasso, Ing.
> ITHACA
> Information Technology for Humanitarian Assistance, Cooperation and Action
> www.ithacaweb.org
> Via Pier Carlo Boggio 61 - 10138 Torino
> Tel: +39.011.1975.1854
>



-- 
Simone Dalmasso, Ing.
ITHACA
Information Technology for Humanitarian Assistance, Cooperation and Action
www.ithacaweb.org
Via Pier Carlo Boggio 61 - 10138 Torino
Tel: +39.011.1975.1854
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20101102/66169e9e/attachment-0001.htm 


More information about the Users mailing list