[OpenLayers-Users] Is there a way to assign a dynamic label on
vector layer?
Mark K. Zanfardino
mzanfardino at gmail.com
Tue Aug 2 11:52:53 EDT 2011
Thanks for the reply. As it happens I'm using MapServer 5.6.x for my
backend. While digging into the XML returned by the WFS query I can not
see any other feature than the polygon, therefore I'm guessing that what
I'm seeking is not going to be possible unless I can some how get the
field data (name in this case) to return from the query. Presuming I
can somehow return the name, I'm still unclear how I might put the field
to use.
On 08/02/2011 12:14 AM, Andreas Hocevar wrote:
> 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
>
>
More information about the Users
mailing list