I have the following style for an OpenLayers vector layer.

Color and Name come from Geoserver/PostGIS.

I red that setting labelSelect to true, user can also click the label, not only the point and fire an event such as featureclick. But no reaction. Clicking the point works, clicking the label does not. For my case, the following code is for points, lines and polys. What am I missing?


var style_d = new OpenLayers.Style({
'fillColor': '${p_color}',
'fillOpacity': 0.8,
'fontColor': 'black',
'pointRadius': 12,
'strokeColor': 'black',
'strokeWidth': 1,
'fontFamily': 'Arial',
'fontSize': 15,
'label': '${p_name}',
'labelAlign': 'tc',
'labelSelect': true,
'labelXOffset': 4,

Try to place that code where you initialize your vector layer:

var vectorLayer = new OpenLayers.Layer.Vector("Valori", {
            //whatever you want
                            //whatever you want
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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