I know it works like a charm for vector layers. But considering that we can make the symbolizers use attribute values in the SLD, I think OpenLayers should support it. But apparently it doesn't.
In the example below, I have a layer with 10 points, where the attribute ogc_fid has the values 1, 2, ..., 10.
I want the stroke width of each point to be the value of its ogc_fid attribute. Here is the whole code, but I will explain the most important parts.
/* Rule */var rule = new OpenLayers.Rule({ filter: filter, symbolizer: { Point: { fillColor: '#dddd00', fillOpacity: 1, pointRadius: 30, strokeWidth: '${ogc_fid}', graphicName: 'circle' }, Text: { label: '${ogc_fid}' } }});Above, I have the rule, where I use strokeWidth: '${ogc_fid}' indicating that I want the stroke width to assume the value of the ogc_fid attribute of its respective point.
I convert it to SLD using the OpenLayers.Format.SLD().write method, and I get this:
${ogc_fid}When I should be getting this:
ogc_fidThe button Custom SLD depending on stroke width (hard coded) set a custom SLD that I hard coded and that contains the above correction. This way, you can see what I am looking for.
My big questions are:
أكثر...
In the example below, I have a layer with 10 points, where the attribute ogc_fid has the values 1, 2, ..., 10.
I want the stroke width of each point to be the value of its ogc_fid attribute. Here is the whole code, but I will explain the most important parts.
/* Rule */var rule = new OpenLayers.Rule({ filter: filter, symbolizer: { Point: { fillColor: '#dddd00', fillOpacity: 1, pointRadius: 30, strokeWidth: '${ogc_fid}', graphicName: 'circle' }, Text: { label: '${ogc_fid}' } }});Above, I have the rule, where I use strokeWidth: '${ogc_fid}' indicating that I want the stroke width to assume the value of the ogc_fid attribute of its respective point.
I convert it to SLD using the OpenLayers.Format.SLD().write method, and I get this:
${ogc_fid}When I should be getting this:
ogc_fidThe button Custom SLD depending on stroke width (hard coded) set a custom SLD that I hard coded and that contains the above correction. This way, you can see what I am looking for.
My big questions are:
- Why doesn't the OpenLayers.Format.SLD().write method do this correction automatically?
- How could I obtain a correct conversion to SLD? Maybe by overloading the OpenLayers.Format.SLD().writemethod. But how??
أكثر...