Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

Example:

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

'1e-1'

is treated mathematically and displayed on the map as

'0.1'

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

share|improve this question

1 Answer 1

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


EDIT

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:

DEMO

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
share|improve this answer
    
I have already tried label: "" + "${tag}" and label: "${tag}" + "" doesn't work either. –  Chau Jan 31 '12 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 '12 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 '12 at 7:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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