[OpenLayers-Users] Numeric Feature attribute values in style.label
Jeff Dege
jeff.dege at korterra.com
Fri Apr 9 16:49:48 EDT 2010
I'm passing GML features to a Vector layer. I need to put the feature name in a label. Some of my features have numeric names, for which the leading zeros are significant. My problem: the leading zeros are being stripped.
I've tracked this down to OpenLayers.Style.createLiteral(), which checks to see if the replacement value is numeric and does a parseFloat() if it is.
OpenLayers.Style.createLiteral = function(value, context, feature) {
if (typeof value == "string" && value.indexOf("${") != -1) {
value = OpenLayers.String.format(value, context, [feature]);
value = (isNaN(value) || !value) ? value : parseFloat(value);
}
return value;
};
I'm not sure why this is being done. It's not like style labels should ever be processed as if they are numeric. They seem to me to be descriptive by definition. Perhaps this same function is being used elsewhere where the numeric conversion is necessary. Still, it leaves me with a problem.
What is the cleanest way to prevent this? It doesn't happen if I add printable characters to the label field: "name: ${name}" works fine. Unfortunately, I need an unadorned name, without extra characters. I've tried adding spaces, and I've tried adding , and neither worked.
Ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100409/a1102e56/attachment.html
More information about the Users
mailing list