Hi List,
I need some help to receive a Vector-Layer with filtered features, because I
need more features than I can request via GET.
Before learning that, I started with filtering a WFS, that worked. I narrowed
it down to a basic example, that is shown below. This is the working code:
OpenLayers.ProxyHost= "/cgi-bin/proxy.cgi?url=";
function init(){
var bounds = new OpenLayers.Bounds(...);
var options = {controls: [],maxExtent: bounds,maxResolution: ...,projection:
"..." };
var map = new OpenLayers.Map('map', options);
//basic Layer for Control -> ok
var wms = new OpenLayers.Layer.WMS("WMS","http://meineDomain.com/wms",
{layers: 'demo:meinLayer', srs: '...',tiled:
'true'});
map.addLayers([wms]);
map.zoomToMaxExtent();
//Create Filter -> works
var filter_1_1 = new OpenLayers.Format.Filter({version: "1.1.0"});
var xml = new OpenLayers.Format.XML();
var filter1 =new Array();
var fsArr= new Array("a1","a2","a3","a4");
for (var f = 0;f<fsArr.length;f++){
var filtertmp = new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "myname",
value: fsArr[f]
});
filter1.push(filtertmp)
};
var myfilter = new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.OR,
filters: filter1
});
myfilter = xml.write(filter_1_1.write(myfilter));
//get 4 features from Layer and show them -> ok
var sellayer = new OpenLayers.Layer.WFS("Selected Features",
"http://meineDomain.com/wfs",
{typename: 'demo:meinLayer',srs: '...',tiled:
'true',filter:myfilter
});
map.addLayers([sellayer]);
map.addControl(new OpenLayers.Control.PanZoomBar());
}
But from the OL-MailingList I learned, that in order to get more features (at
the moment, I only can get 15 features via GET) I need to use a vector-layer
with WFS-Protocol and a BBOX-strategy, because this sends a POST-Request whose
length is not limited. I can't get it to work.
//Without Filter I get all features (> 2000) -> works, all features are shown
after a nice coffee break
var sellayer = new OpenLayers.Layer.Vector("Selected Features", {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
url: "http://meineDomain.com/wfs",
featureType: "meinLayer",
featureNS: "http://meineDomain.com/demo"
})
});
}
//But adding the same filter as above to the layer-parameters of the
vector-layer causes an error
//"uncaught exception: Filter writing not supported for rule type: undefined"
in firebug
var sellayer = new OpenLayers.Layer.Vector("Selected Features", {
strategies: [new OpenLayers.Strategy.BBOX()],
filter: myfilter,
protocol: new OpenLayers.Protocol.WFS({
url: "http://meineDomain.com/wfs",
featureType: "meinLayer",
featureNS: "http://meineDomain.com/demo"
})
});
moving the filter to the WFS-options doesn't cause an error, but doesn't filter
anything.
Any ideas for filtering a vector-layer or what rule type I should define?
Last question: is "sellayer.refresh();" correct for forcing the layer to be
redrawn and show the features without panning manually?
Thanks for answering.
Barbara
____________________________________________________________________
WEB.DE MillionenKlick: Kostenlos tippen, täglich 1 Million gewinnen!
http://produkte.web.de/go/07/
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users