Thanks so much!!! That's just what I was looking for.  My features are now 
displaying as I'd hoped.  Is it difficult to extend this to change features 
that are selected onhover?  I added:
var selrules = [new OpenLayers.Rule({
symbolizer: {strokeColor:"blue",strokeWidth: 2},
elseFilter: true
})];
oStyleMap.styles["select"].addRules(selrules);

to your .js file but nothing happens when I hover over the points (it's a bit 
gawdy but I just wanted to see if it would work).  I think I need to add a 
control but haven't tried this before.  Will this work?  The points aren't 
currently changing.  Are there additional considerations that I need to think 
about.  I'm just trying to port my old mapserver interface to openlayers and 
any help is appreciated.  Thanks again,
Todd

-----Original Message-----
From: Alexandre Dube [mailto:[EMAIL PROTECTED]
Sent: Tue 7/29/2008 3:22 PM
To: Brenningmeyer, Todd
Cc: [email protected]
Subject: Re: [OpenLayers-Users] wfs stylemap example?
 
Hi Todd,

I have some to share. My WFS layer contains line features ( roads ) and 
they have different color depending on their type ( Local road, Highway, 
etc ). I hope this can be of any help :

============= otherfile.js =============

// prepare to style the data
var oStyleMap = new OpenLayers.StyleMap();

// Array of symbolizer and other values for ROL_CO_CLA attribute
// this will be used to create a html select list and will be used
// as the symbolizer array for the addUniqueValueRules function
// sorry, there's some french words here :)
var aRoadType = new Array();
aRoadType = {
AUT: {
text: "Autoroute",
strokeColor: "#ff0000", strokeWidth: 3 },
NAT: {
text: "Nationale",
strokeColor:"#ff8c00", strokeWidth: 2 },
REG: {
text: "Régionale - Reg",
strokeColor:"#ff8c00", strokeWidth: 2 },
COL: {
text: "Régionale - Col",
strokeColor:"#ff8c00", strokeWidth: 2 },
ACC: {
text: "Locale - Acc",
strokeColor:"#d2b48c", strokeWidth: 2 },
LOC: {
text: "Locale - Loc",
strokeColor:"#d2b48c", strokeWidth: 2 },
ACH: {
text: "Chemin forestier - Ach",
strokeColor:"#734c00", strokeWidth: 2 },
MRN: {
text:"Chemin forestier - Mrn",
strokeColor:"#734c00", strokeWidth: 2 }
}

// a style will applies to each drawned vector feature depending on
// the ROL_CO_CLA attribute value. It will match the good value and applies
// the corresponding symbolizers
oStyleMap.addUniqueValueRules("default", "ROL_CO_CLA", aRoadType);

// If no rules applies to the current vector feature, that means it's
// not a road, but an other type of feature like a circle for drag
// control. The "elseFilter: true" is used to display those vectors.
var rules = [new OpenLayers.Rule({
symbolizer: {strokeColor:"#FF0000",strokeWidth: 2},
elseFilter: true
})];
oStyleMap.styles["default"].addRules(rules);

============= yourHTMLFile.html =============

--- inside your <head> section ---
<script src="otherfile.js"></script>

--- inside your init() function ---

OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';

// then some variables... map definition... base layer ... some WMS 
layers ... and :

olWFSRoads = new OpenLayers.Layer.WFS(
"Roads - WFS", sMSURL,
{ typename: "roads", map: sMapPath },
{ extractAttributes: true, minScale: 49999,
typename: "roads", styleMap: oStyleMap
}
);

// then addlayers, controls, etc. and your <body>

Brenningmeyer, Todd wrote:
> Hello,
> Does anyone have an example code snippet that shows how to use a stylemap 
> with wfs data that is being served as vectors (I'm trying to serve up 
> points).  I've been trying to get this to work using some of the examples on 
> the wiki but I can't quite get the syntax to work properly.  If anyone has 
> ideas or an example that would be great.  
> Thanks,
> Todd
> _______________________________________________
> Users mailing list
> [email protected]
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com


_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to