2

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?

Thanks

var style_d = new OpenLayers.Style({
'fillColor': '${p_color}',
'fillOpacity': 0.8,
'fontColor': 'black',
'pointRadius': 12,
'fontWeight':'bold',
'strokeColor': 'black',
'strokeWidth': 1,
'fontFamily': 'Arial',
'fontSize': 15,
'label': '${p_name}',
'labelAlign': 'tc',
'labelOutlineColor':'white',
'labelOutlineWidth':3,
'labelOutlineOpacity':0,
'labelSelect': true,
'labelXOffset': 4,
'labelYOffset':4});
1

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

var vectorLayer = new OpenLayers.Layer.Vector("Valori", {
    [...]
    eventListeners:{
        'featureselected':function(evt){                
            //whatever you want
        },
        'featureunselected':function(evt){
                            //whatever you want
        }
    }
    [...]
}

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.