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