[OpenLayers-Users] Is there a way to assign a dynamic label on vector layer?

Andreas Hocevar ahocevar at opengeo.org
Tue Aug 2 03:14:49 EDT 2011


Hi,

the OpenLayers configuration looks correct. But by default, you cannot use "name" as feature attribute in WFS. If your WFS is GeoServer, you can override this in the Services - WFS settings by checking the "Override GML Attributes" checkbox.

Andreas.

On Aug 2, 2011, at 03:01 , Mark K. Zanfardino wrote:

> I have a vector layer that is generated via a WFS layer. I'd like to label the vectors according to a field in the source WFS protocol.  My layer is currently defined as follows (note that I have used the substitution "${name}" in the label parameter).  Currently this renders the vectors with the label as "undefined".  I'd like to use the name field from the data source as the label for the vectors.  Please let me know if I can provide more detail.
> 
> tens = new OpenLayers.Layer.Vector("TENS (Vector)",
>    {
>      styleMap: new OpenLayers.StyleMap({
>        fillColor: '#faff6a',
>        fillOpacity: 0.5,
>        strokeColor: '#000000',
>        strokeOpacity: 0.5,
>        strokeWidth: 1,
>        pointRadius: 4,
>        label : "${name}"
>      }),
>      strategies: [new OpenLayers.Strategy.BBOX()],
>      protocol: new OpenLayers.Protocol.WFS({
>          srsName: "EPSG:4326",
>          url: mapPath,
>          featureType: "tenszones",
>          featurePrefix: "ms",
>              geometryName: "msGeometry"
>      }),
>      filter: new OpenLayers.Filter.Comparison({
>          type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
>          property: "name",
>          value: "Countywide"
>      }),
>      filter: new OpenLayers.Filter.Comparison({
>          type: OpenLayers.Filter.Comparison.LIKE,
>          property: "name",
>          value: "DOW*"
>      })},
>      {
>          isBaseLayer: false,
>          buffer: 0
>  });
> 
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list