[OpenLayers-Users] Labels on WFS layers

Arnd Wippermann arnd.wippermann at web.de
Mon Mar 8 17:22:26 EST 2010


Perhaps there is something wrong with the way you declare your style for
your layer. 
 
The below code works on WFS layer. ADMIN_NAME is an attribute of the wfs.
 
var styleMapLabelDS;
 
function set_styleMapLabelDS()
{
    var template = {
        strokeColor: "#0000FF",
        strokeOpacity: 1,
        strokeWidth: 3,
        fillColor: "#00AAFF",
        fillOpacity: 1,
        pointRadius: 5,
        pointerEvents: "visiblePainted",
 
        label : "${ADMIN_NAME}",
 
        labelOffsetX: "10",
        labelOffsetY: "-10",
        fontColor: "red",
        fontSize: 10,
        fontFamily: "Arial",
        fontWeight: "bold",
        labelAlign: "lt"
    };
    var templateB = {
        strokeColor: "#FF00FF",
        strokeOpacity: 1,
        strokeWidth: 3,
        fillColor: "#AA00FF",
        fillOpacity: 1,
        pointRadius: 5,
        pointerEvents: "visiblePainted",
 
        label : "${ADMIN_NAME}",
 
        labelOffsetX: "10",
        labelOffsetY: "-10",
        fontColor: "blue",
        fontSize: 10,
        fontFamily: "Arial",
        fontWeight: "bold",
        labelAlign: "lt"
    };
    styleMapLabelDS = new OpenLayers.StyleMap( { "default" : new
OpenLayers.Style(template), "select" : new OpenLayers.Style(templateB) } );
}
 
set_styleMapLabelDS();
myWFS["styleMap"]=styleMapLabelDS;
myWFS.redraw();

http://gis.ibbeck.de/OLClient/OLClient.asp?WMC=./data/WMC/wfs_germany_reproj
ect_and_labels.wmc.xml
 
Arnd

 
  _____  

Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Luís de Sousa
Gesendet: Montag, 8. März 2010 21:16
An: users at openlayers.org
Betreff: Re: [OpenLayers-Users] Labels on WFS layers


Hello again,

I can't get this to work in any way, no errors at runtime but no labels
either. The label properties is listed in the vector style specification,
among other that work perfectly:

http://dev.openlayers.org/releases/OpenLayers-2.8/doc/apidocs/files/OpenLaye
rs/Feature/Vector-js.html

It can also be found a great deal of discussion on this list and elsewhere
about the development of this functionality, mostly from 2008. Has vector
labeling been fully implemented in OpenLayers-2.8? If not, what other ways
are there to get this to work?

Thank you,

Luís


2010/3/5 Luís de Sousa <luis.a.de.sousa at gmail.com>


Hello everyone,

I'm trying to set labels on a point layer using code like this:

wfs2.style = OpenLayers.Util.applyDefaults(
            {
                strokeColor: "#008000",
                fillColor: "#FFFF00",
                strokeWidth: "2.0",
                label: "${someAtribute}",
                fontColor: "#FF0000"
             }

I don't get any errors at runtime, but no label appears. What am I missing?

Thanks,

Luís




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100308/f0312aae/attachment.html


More information about the Users mailing list