FW: [OpenLayers-Users] Multiple Styles for grouped vector layers with multiple featuretypes possible?

Andrew Stewart Andrew.Stewart at reddeer.ca
Sun Mar 6 17:09:33 EST 2011


Thanks Arnd, I am trying to use the method of adding/removing featureTypes from the code example you sent by adding array items to the featureType and refreshing the layer, except it doesn't refresh. I am changing the featureType here from "Attraction", "Fire_Hall" to the below but the other features remain on and the new ones are not added, any idea why>?

    alert(layer_AOIs_WFS.options.protocol.featureType);
    
    var array_FeatureType = [];
    array_FeatureType.push("Hospital");
    
    layer_AOIs_WFS.options.protocol.featureType = array_FeatureType;
    layer_AOIs_WFS.refresh({force:true}); 





-----Original Message-----
From: arnd.wippermann at web.de [mailto:arnd.wippermann at web.de] 
Sent: March 06, 2011 6:12 AM
To: Andrew Stewart
Cc: users at openlayers.org
Subject: AW: [OpenLayers-Users] Multiple Styles for grouped vector layers with multiple featuretypes possible?

Hi,
 
You can use a styleMap with context. The WFS response from MapServer look
like 

'<ms:LAYER1 fid="LAYER1.WFS, triangle No. 4">'. 

The fid contains the typename and OpenLayers set this as feature.fid. If
that apply to other Mapservers, i don't know.

var context = {
    getColor : function (ft){
        if(ft.fid.search(/^LAYER1/)==0)
            return '#00FF00';
        else if(ft.fid.search(/^LAYER2/)==0)
            return '#FF00FF';
        else if(ft.fid.search(/^LAYER3/)==0)
            return '#0000FF';
        else
            return '#FF0000';
    }
};


Example :
http://gis.ibbeck.de/ginfo/apps/OLExamples/OL29/WFS_with_multiple_featureTyp
es.asp

Arnd


-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Planet)x
Gesendet: Donnerstag, 3. März 2011 23:06
An: users at openlayers.org
Betreff: [OpenLayers-Users] Multiple Styles for grouped vector layers with
multiple featuretypes possible?

 With my below code I have multiple featuretypes grouped into a single WFS
layer and they are both displaying properly. My problem is I need to define
2 different styles one for each featuretype. Can I do it this way somehow or
do I need to modify my code?

//Test Vector Style
   var style_attraction = OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default']);
       style_attraction.externalGraphic = 'sask.jpg';
       style_attraction.cursor =  'hand';
       style_attraction.graphicHeight = 35;
       style_attraction.graphicWidth = 35;
       style_attraction.graphicOpacity = 0.8;
   
     //Areas of Interest Group
           var layer_AOIs_wfs = new OpenLayers.Layer.Vector("Attraction", {
                minScale: 125000,
                maxScale: 99,
                styleMap: new OpenLayers.StyleMap(style_attraction),
                strategies: [new OpenLayers.Strategy.BBOX()],
                
                 protocol: new OpenLayers.Protocol.WFS({
                 url: wfs,
                 featureType: ["Attraction", "Fire_Hall"],
                 featureNS: "http://www.intergraph.com/geomedia/gml",
                 featurePrefix: "gmgml",
                 srsName: "EPSG:3776",
                 geometryName: "Geometry",
                 version: "1.1.0"
                })
                });
   
     //Add Vector Layers to Map
     map.addLayer(layer_AOIs_wfs);

--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Multiple-Styles-for-grouped-vector-la
yers-with-multiple-featuretypes-possible-tp6086563p6086563.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



[This message has been scanned for security content threats and viruses.]

[The City of Red Deer I.T. Services asks that you please consider the environment before printing this e-mail.]






More information about the Users mailing list