Does the a wms layer in openlayers have "maxfeatures" option?
I'm asking this because my wms layer contains allot of points ( > 100.000). When zoomed in I don't want the rest of the features (not sure if you call it features when using wms) to be rendered.
When I was using WFS, this was my code:
wfs = new OpenLayers.Layer.Vector("WFS", {
strategies: [new OpenLayers.Strategy.BBOX({
resFactor: 1,
ratio:1
})],
protocol: new OpenLayers.Protocol.WFS({
maxFeatures:1000,
url: "my url",
featureType: "my_featuretype",
featureNS: "my_feature ns",
version: "1.1.0"
})
});
How can I accomplish the same render functionality with a wms layer?
Edit
Solution: Hide the layer at a certain zoomlevel. This prevents a big amount of features to be loaded.
code:
map.events.on({ "zoomend": function (e) {
if (this.getZoom() > 7) {
layer.setVisibility(true);
}
else {
layer.setVisibility(false);
}
}
});
Best Answer
A WMS uses images generated on the server so any filtering also has to be done on the server. The WMS specification does not include a MAXFEATURES parameter, but many map servers do allow filtering.
Your tag implies you are using GeoServer so have a look at its WMS MaxFeatures option.
This is a vendor specific parameter, which can be added to your OpenLayers WMS configuration.