AW: [OpenLayers-Users] Re: Hide/Show different features in one Layer ?

Arnd Wippermann arnd.wippermann at web.de
Fri Mar 2 07:56:46 EST 2012


Hi,

to use multiple featureTypes i modified OpenLayers.Protocol.WFS.v1.read as
follows

    read: function(options) {
        OpenLayers.Protocol.prototype.read.apply(this, arguments);
        options = OpenLayers.Util.extend({}, options);
        OpenLayers.Util.applyDefaults(options, this.options || {});
        var response = new OpenLayers.Protocol.Response({requestType:
"read"});

        /*  ###########################################################
            übernommen von patch #1839 (Protocol\WFS\v1.js),
            node durch data ersetzt und schemaLocation ausgeblendet
            ###########################################################
        */
        var data = this.format.createElementNSPlus("wfs:GetFeature", {
            attributes: {
                service: "WFS",
                version: this.version,
                outputFormat: options && options.outputFormat,
                maxFeatures: options && options.maxFeatures
                //"xsi:schemaLocation": this.schemaLocationAttr(options)
            }
        });
        if (typeof this.featureType == "string") {
            this.format.writeNode("Query", options, data);
        } else {
            for (var i=0,len = this.featureType.length; i<len; i++) {
                options.featureType = this.featureType[i];
                this.format.writeNode("Query", options, data);
            }
        }

        /*  ###########################################################
            wird ersetzt durch obige Anweisung
        var data = OpenLayers.Format.XML.prototype.write.apply(
            this.format, [this.format.writeNode("wfs:GetFeature", options)]
        );
            ###########################################################
        */

        response.priv = OpenLayers.Request.POST({
            url: options.url,
            callback: this.createCallback(this.handleRead, response,
options),
            params: options.params,
            headers: options.headers,
            data: data
        });

        return response;
    },

I use this with OL 2.10, but it should also work with OL 2.11.

The url is the adress of the wfs server. I use a proxy script 
only to hide the path to the mapfile.

Arnd


-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Albert
Gesendet: Donnerstag, 1. März 2012 22:32
An: openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] Re: Hide/Show different features in one Layer ?

interesting .. I would like to try that.

so here :

var myLayer = new OpenLayers.Layer.Vector("WFS protocol", {
    strategies: [new OpenLayers.Strategy.BBOX()],
    protocol: new OpenLayers.Protocol.WFS({
                  "url":  "WFS_with_multiple_featureTypes_proxy.asp",
                  "featureType": ["LAYER1","LAYER2","LAYER3"],
                   >>> etc.

my url will be what exactly ?
and my featureType array will contain my layers from geoserver right ?
all of them will appear over my map like one layer as usual right ?

thank you for helping. 

--
View this message in context:
http://osgeo-org.1560.n6.nabble.com/Hide-Show-different-features-in-one-Laye
r-tp4535434p4537447.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list