AW: [OpenLayers-Users] Multiple Styles for grouped vector layerswith
multiple featuretypes possible?
Arnd Wippermann
arnd.wippermann at web.de
Mon Mar 7 13:44:46 EST 2011
Hi,
I can't help. I'm not able to understand, what's going on.
If I use an unpatched version of protocol.WFS.v1 and an array for
featureType:["LAYER1", "LAYER2", "LAYER3"], the POST request is like
<wfs:getfeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.0.0" maxFeatures="100"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:query typeName="LAYER1,LAYER2,LAYER3">...
If i change the featureType by layerWFS.options.protocol.featureType =
["LAYER1", "LAYER2"];
the POST request after a refresh is as above.
A firebug console.log(layerWFS.options.protocol.featureType) shows the
changed value.
It seems the protocol takes not the changed value, but use the initialed
values.
Perhaps it's the read function in OpenLayers.Protocol.WFS.v1, this function
I have changed in the patched version.
By the way I get only the features for the first entry of the featureType
array. I use MapServer.
Arnd
-----Ursprüngliche Nachricht-----
Von: Andrew Stewart [mailto:Andrew.Stewart at reddeer.ca]
Gesendet: Sonntag, 6. März 2011 23:24
An: 'arnd.wippermann at web.de'
Cc: users at openlayers.org
Betreff: RE: [OpenLayers-Users] Multiple Styles for grouped vector
layerswith multiple featuretypes possible?
I am able to use multiple typenames when I define the layer itself like -
//Grouped AOI layer
var layer_AOIs_WFS = new OpenLayers.Layer.Vector("Areas of
Interest", {
minScale: 125000,
maxScale: 99,
//visibility: false,
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
url: wfs,
featureType:
["Attraction","Fire_Hall","Community_Shelter"],
featureNS: "http://www.intergraph.com/geomedia/gml",
featurePrefix: "gmgml",
srsName: "EPSG:3776",
geometryName: "Geometry",
version: "1.1.0"
})
});
And then if I add this layer to the map all of the correct layers appear.
So when I used your example code I passed the new array of featureType
["Name 1, "Name 2", etc]
By setting layer_AOIs_WFS.options.protocol.featureType = array_Features;
Then I have tried refresh with force, redraw with force and still the same
vector features appear.. So not sure why. I will try to modify some stuff
might I have to refresh the map also?
-----Original Message-----
From: arnd.wippermann at web.de [mailto:arnd.wippermann at web.de]
Sent: March 06, 2011 3:20 PM
To: Andrew Stewart
Cc: users at openlayers.org
Subject: AW: [OpenLayers-Users] Multiple Styles for grouped vector
layerswith multiple featuretypes possible?
Hi Andrew,
I have to patch the protocol.WFS.v1 to get multiple typenames for one WFS
layer working. From your previous post and the code, I have thought, that
you have got it also working.
If your code works and you get both typenames from your WFS, then I have no
clue, why my code not working for you.
Arnd
-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Andrew
Stewart
Gesendet: Sonntag, 6. März 2011 23:10
An: users at openlayers.org
Betreff: FW: [OpenLayers-Users] Multiple Styles for grouped vector
layerswith multiple featuretypes possible?
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.]
[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