Thanks Matt for your help, it has been really helpful:<div>I post my solution:</div><div><br><div><div><i>var sites = new OpenLayers.Layer.Vector('Sites',{</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                                </i></span><i>styleMap: styleMap,</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                                </i></span><i>strategies: [</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                                        </i></span><i>new OpenLayers.Strategy.Filter({</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                                                </i></span><i>filter: new OpenLayers.Filter.Comparison({type: OpenLayers.Filter.Comparison.EQUAL_TO,property: 'approved',value: "true"})</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                                        </i></span><i>}),</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                                        </i></span><i>new OpenLayers.Strategy.BBOX({ratio: 1, resFactor: 1})</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                                </i></span><i>], </i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                                </i></span><i>projection: new OpenLayers.Projection("EPSG:4326"), </i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                                </i></span><i>protocol: new OpenLayers.Protocol.WFS({ </i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                                        </i></span><i>version: "1.1.0", </i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                                </i></span><i> srsName: "EPSG:4326",</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                                        </i></span><i>url: '/geoserver/wfs/',</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                                        </i></span><i>featureType: 'fs',</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                                </i></span><i> featurePrefix: "prefix",</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                                        </i></span><i>geometryName: 'point',</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                                        </i></span><i>maxFeatures: "100"</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>                                </i></span><i>})</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>                        </i></span><i>});</i></div></div><div><br></div><div>the category filter is set dynamically when the user chooses one:</div>
<div><br></div><div><div><i><div>new Ext.form.ComboBox({</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>id: 'category',</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>store: new Ext.data.ArrayStore({</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                </span>fields: ['id','category'],</div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>data: sitesCategories</div><div>
<span class="Apple-tab-span" style="white-space:pre">                                        </span>}),</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>valueField: 'id',</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>displayField: 'category',</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                        </span>mode: 'local',</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>typeAhead: true,</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>forceSelection: true,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                        </span>emptyText: 'Select a Category...',</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>triggerAction: 'all',</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                        </span>editable: false,</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>width: 200,</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>listeners: {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                </span>select: function(){</div><div><span class="Apple-tab-span" style="white-space:pre">                                                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                                                        </span>if(this.value !== 'ALL'){</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>sites.filter = new OpenLayers.Filter.Comparison({type: OpenLayers.Filter.Comparison.EQUAL_TO,property: 'category',value: this.value});</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                        </span>}else{sites.filter = null;}</div><div><span class="Apple-tab-span" style="white-space:pre">                                                        </span>sites.redraw();</div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                        </span>}//end listeners</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>})// end combo box</div></i></div><div><br></div><div>in that way each time the user pans, zooms or selects a category the layer is redrawed and are always keps at most 100 features.</div>
<div><br></div><div>Thanks a lot.</div><div><br></div><div class="gmail_quote">2010/11/23 Matt Priour <span dir="ltr"><<a href="mailto:mpriour@kestrelcomputer.com">mpriour@kestrelcomputer.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
In memory spatial filtering is a computationally expensive process. IE (<9) has a significantly!!! slower js engine than other browsers, so doing the filtering in this way is very slow on IE.<br>
The better way to accomplish what you are trying to do is to use a WFS or other "feature server" and do the filtering on the server side.<br>
To use a WFS you would do something like this:<br>
<br>
var catFilter = new OpenLayers.Filter({...});<br>
<br>
var wfsVector = new OpenLayers.Layer.Vector('my wfs layer',{<br>
protocol:new OpenLayers.Protocol.WFS({ ... }),<br>
strategies:[new OpenLayers.Strategy.BBOX()],<br>
style:new OpenLayers.Style({rules:[catFilter]})<br>
});<br>
<br>
When the user zooms or pans, the WFS will be called and you will get the features in the view extent.<br>
When the user chooses a category to filter the features by, you write the correct value to the catFilter and then call wfsVector.redraw()<br>
<br>
OpenLayers.Vector.redraw() - will just redraw the existing features and re-evaluate the styles & filters. It will not request features from the WFS.<br>
<br>
Matt Priour<br>
Kestrel Computer Consutling<br>
<br>
<br>
<br>
From: Simone Dalmasso<br>
Sent: Tuesday, November 23, 2010 4:21 AM<br>
To: <a href="mailto:users@geoext.org" target="_blank">users@geoext.org</a><br>
Subject: [Users] internet explorer extremely slow with spatial filter<div><div></div><div class="h5"><br>
<br>
<br>
Hi, I need to have my map to show features if they are in the current extent and if they match a selected category.<br>
So I've written a filter function that uses the filterBy of the FeatureStore:<br>
<br>
<br>
function sitesFilter(){<br>
var extent = map.getExtent();<br>
featureStore.filterBy(function(record){<br>
var currentCategory = Ext.getCmp('category').value;<br>
var feature = record.data.feature;<br>
if(feature.data.category == currentCategory){<br>
return extent.containsLonLat(new OpenLayers.LonLat(feature.geometry.x,feature.geometry.y));<br>
}else if(!currentCategory || currentCategory == 'ALL'){<br>
return extent.containsLonLat(new OpenLayers.LonLat(feature.geometry.x,feature.geometry.y));<br>
}<br>
});<br>
<br>
<br>
this is called on zoomend, moveend or when a category is chosen.<br>
All works pretty well and quick with each browser except for ie which is extremely slow and unusable.<br>
<br>
<br>
Is there something I can do to speed it up?<br>
<br>
<br>
Thanks in advance<br>
-- <br>
Simone<br>
<br>
<br>
<br>
<br></div></div>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@geoext.org" target="_blank">Users@geoext.org</a><br>
<a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a> <br>
</blockquote></div><br><br clear="all"><br>-- <br>Simone Dalmasso, Ing.<br>ITHACA<br>Information Technology for Humanitarian Assistance, Cooperation and Action<br><a href="http://www.ithacaweb.org">www.ithacaweb.org</a><br>
Via Pier Carlo Boggio 61 - 10138 Torino<br>Tel: +39.011.1975.1854<br>
</div></div>