1

I am facing an issue, that I want to show multiple labels on each polygon of OpenLayers. I am defining styles in style editor of a layer.like

 <sld:Label>
           ogc:PropertyName>XYZ< /ogc:PropertyName>             
 </sld:Label>

where xyz is one of the columns in my query. Now I want to show one more column on the polygon from query and the attribute should be one after the other on the polygon.

1 Answer 1

1

In general SLD (though I haven't tested it in OpenLayers) you can do:

<sld:Label>
       <ogc:PropertyName>XYZ</ogc:PropertyName>             
       <ogc:PropertyName>ABC</ogc:PropertyName>             
 </sld:Label>

and they will be concatenated. If you need more than one white space you can play around with a [CDATA] block to contain extra white space.

6
  • Yes. I was using the same way but the second property is comming null from database. Because of this region the entire label is not showing.
    – user18260
    Commented Jul 2, 2013 at 13:06
  • replace the nulls with empty strings
    – Ian Turton
    Commented Jul 2, 2013 at 13:16
  • I need to check whether the property is null. If it is null then need to show NA else the value. How to achieve this in SLD?
    – user18260
    Commented Jul 2, 2013 at 13:53
  • No standard way - if you are using GeoServer check out the functions
    – Ian Turton
    Commented Jul 2, 2013 at 13:58
  • Thanks for your help iant. I have handling null values in the query itself.
    – user18260
    Commented Jul 2, 2013 at 14:29

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.