I have a vector layer in OpenLayers containing a few point features. Each of my features have an attribute tag which contains a short text identifying the feature.


tag: '1e-1'

Applied to my vector layer I have a point style where I specify that I want to display my tag as a label above the point:

new OpenLayers.Rule(
    symbolizer: {
        "Point": {
            label: "${tag}"

The problem:
My problem is that my data in this case has some very unfortunate tags, since


is treated mathematically and displayed on the map as


Can I avoid the formatting somehow without overriding a bunch of OpenLayers objects and methods?

1 Answer 1


Try something like label: ${tag} + ""?


So that does not work. I've been at it all day with no results. I've posted a DEMO so others can play around with to help solve this problem:


My only other two suggestions are

  1. use something like brackets as a "style" for your labels so instead of having a simple 1e-1 value, you have [1e-1] or .: 1e-1 :. like THIS.
  2. Use spaces before and after the dash like this 1e - 1
  • I have already tried label: "" + "${tag}" and label: "${tag}" + "" doesn't work either.
    – Chau
    Jan 31, 2012 at 7:22
  • @Chau : See my update. Sorry. that's all i got (weaksauce). If i think of anything else, i'll re-post.
    – CaptDragon
    Jan 31, 2012 at 20:23
  • Great work! Even though the problem is far from solved, you definitely explored the possibilities at hand! Thanks a lot for your input - I might very well use your stylish suggestion :)
    – Chau
    Feb 1, 2012 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.