ops sorry, I misunderstood your question. The styling I suggested would work with a vector layer. a WMS request delivers an image, so there isn't much OL can do about it. you can though change the layer parameters on the fly, so that with the next WMS request the map will be requested with a different sld (you have to have preconfigured slds of course). You can add such parameter to the layer with: mergeNewParams({SLD: "your_sld_uri", STYLES: null).

See the thread
http://old.nabble.com/dynamic-SLD-with-openlayers-td21367731.html

Good luck

Ken wrote:
Hi, thanks for the response.

I have messed with this, but I was under the impression this would not work with a WMS layer? Would I need to convert my data to GML or something similar in order to use a StyleMap on it?

I have had issues with GML in the past, so prefer not to go that route if I do not have to.

Ken

On 08/09/2010 11:41 AM, Moataz Elmasry wrote:
See this example
http://www.openlayers.org/dev/examples/stylemap.html

Where with StyleMap you can change the style on the fly through a
function, where this function is bound to a certain attribute, for example:

var defaultTemplate = {
fillColor : "${getStyleColor}",
fillOpacity : 0.5,
strokeColor : "${getStyleColor}",
strokeOpacity : 1,
strokeWidth : 2,
pointRadius : 4,
label : "${getName}"
};

getStyleColor = function(feature) {
if (feature.x) return "red"
else if (feature.y) return "blue";
}

var customStyleMap = new OpenLayers.StyleMap({
"default": new OpenLayers.Style(defaultTemplate, {context: context}),
"select": new OpenLayers.Style({
strokeColor: "red",
strokeOpacity : 1
})
});



Ken wrote:
Doing some brain storming on how best to approach styling one dataset
based on the information in a database.

What we have is a polygon layer, currently a shape file displayed via
WMS, but I can convert it to whatever I need it to be.

We also have a database of information that pertains to each polygon
and that changes as new information is added. This is currently an
Access database accessible via an ODBC connection.

What I would like to do is change the fill color of my polygons based
on the contents of the database on the fly. So whenever someone
refreshes the map it will go to the database and use the data there to
determine what colors the polygons should be.

Thoughts on best approach?

Thanks,

Ken

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


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

Reply via email to