[OpenLayers-Users] Layer Styling - Column names

Arnd Wippermann arnd.wippermann at web.de
Fri Jul 20 15:01:25 PDT 2012


Have a look at BaseTypes.js, OpenLayers.String.format.
 
// Loop through all subs. Example: ${a.b.c}
// 0 -> replacement = context[a];
// 1 -> replacement = context[a][b];
// 2 -> replacement = context[a][b][c];
var subs = match.split(/\.+/);

OL use the period to split the token in parts. 
So it seems, that column names with a period cann't displayed as labels.
 
In which context one can use this behavoiur of OL, i haven't a clue.
 
Regards
Arnd
 
  _____  

Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von uk52rob
Gesendet: Donnerstag, 19. Juli 2012 23:38
An: openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] Layer Styling - Column names


I'm having issues getting OpenLayers.Style to pick up my column names as
they have a period in their names, e.g. 'sites.name'



Here is an example:

var style = new OpenLayers.Style();
                //rule used for all polygons
                var rule_sites = new OpenLayers.Rule({
                symbolizer: {
                fillColor: "#ff9a9a",
                fillOpacity: 0.5,
                strokeColor: "#000000",
                strokeWidth: 1,
                strokeDashstyle: "solid",
                label: " ${sites.name}",
                labelAlign: "cc",
                fontColor: "#333333",
                fontOpacity: 0.9,
                fontFamily: "Arial",
                fontSize: 14}
                    });


This simply displays '${sites.name}' on the map, whereas if I change the
column name from 'sites.name' to 'name' it works fine.


I have tried '${sites\\.name}' to escape the period, but this does not work.


Does anyone know how to get around this (without having to change the column
names..)?


Thanks,

Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120721/2ca94080/attachment.html>


More information about the Users mailing list