[Users] internet explorer extremely slow with spatial filter
Matt Priour
mpriour at kestrelcomputer.com
Tue Nov 23 16:32:54 CET 2010
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.
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.
To use a WFS you would do something like this:
var catFilter = new OpenLayers.Filter({...});
var wfsVector = new OpenLayers.Layer.Vector('my wfs layer',{
protocol:new OpenLayers.Protocol.WFS({ ... }),
strategies:[new OpenLayers.Strategy.BBOX()],
style:new OpenLayers.Style({rules:[catFilter]})
});
When the user zooms or pans, the WFS will be called and you will get the
features in the view extent.
When the user chooses a category to filter the features by, you write the
correct value to the catFilter and then call wfsVector.redraw()
OpenLayers.Vector.redraw() - will just redraw the existing features and
re-evaluate the styles & filters. It will not request features from the WFS.
Matt Priour
Kestrel Computer Consutling
From: Simone Dalmasso
Sent: Tuesday, November 23, 2010 4:21 AM
To: users at geoext.org
Subject: [Users] internet explorer extremely slow with spatial filter
Hi, I need to have my map to show features if they are in the current extent
and if they match a selected category.
So I've written a filter function that uses the filterBy of the
FeatureStore:
function sitesFilter(){
var extent = map.getExtent();
featureStore.filterBy(function(record){
var currentCategory = Ext.getCmp('category').value;
var feature = record.data.feature;
if(feature.data.category == currentCategory){
return extent.containsLonLat(new
OpenLayers.LonLat(feature.geometry.x,feature.geometry.y));
}else if(!currentCategory || currentCategory == 'ALL'){
return extent.containsLonLat(new
OpenLayers.LonLat(feature.geometry.x,feature.geometry.y));
}
});
this is called on zoomend, moveend or when a category is chosen.
All works pretty well and quick with each browser except for ie which is
extremely slow and unusable.
Is there something I can do to speed it up?
Thanks in advance
--
Simone
_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
More information about the Users
mailing list