Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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);
        }
    }
});   
share|improve this question
    
If taking the approach of hiding the layer then you can use the numZoomLevels or minScale/maxScale layer properties dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/… –  geographika Oct 26 '11 at 13:54
add comment

2 Answers

up vote 5 down vote accepted

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.

var wms = new OpenLayers.Layer.WMS("Test",
                                   "http://myurl...",
                                   {layers: "test", maxfeatures: 500});
share|improve this answer
    
Thanks again haha. You've been a great help so far. I noticed that it only does render the features inside the view port, which is good! I set the visibility to false when a certain zoom level is reached. This worked, but I'll ad the maxfeatures to the layer aswel to be sure. –  Boedy Oct 26 '11 at 11:35
add comment

in openlayers Cluster Strategy maybe solve your problem for big dataset..See OpenLayers Cluster Strategy .. in this method you dont need to limit yourself...

and the same handling big dataset problem in google you can read this...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.