2

In OpenLayers, I have a Vector layer with a StyleMap and SelectFeature and ModifyFeature controls, like this:

vector_layer = new OpenLayers.Layer.Vector('My Vector Layer', {extractAttributes: true,
            styleMap: new OpenLayers.StyleMap({'default':{
                strokeColor: "${customColor}",
                strokeOpacity: 1,
                strokeWidth: 2,
                fillColor: "${customColor}",
                fillOpacity: 0.5
            }}) }); 
map.addLayer(vector_layer);


selectControl = new OpenLayers.Control.SelectFeature(vector_layer,
                {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
map.addControl(selectControl);
selectControl.activate();
modify_control = new OpenLayers.Control.ModifyFeature(vector_layer);
map.addControl(modify_control);

When I tick a checkbox on the page, the ModifyFeature control is activated:

modify_control.activate();
modify_control.mode |= OpenLayers.Control.ModifyFeature.ROTATE;
modify_control.mode |= OpenLayers.Control.ModifyFeature.DRAG;

The problem is this: when I remove the StyleMap, ModifyFeature shows the handles to drag and rotate the feature. With the StyleMap, they are not visible. Any suggestions how to fix this?

1

You have encountered the same problem I did, here is the question I asked. I'm convinced that this is a bug in OpenLayers and will be opening a bug tracker issue for it. In the meantime I have found a work around and have posted an answer against my original question. Take a look as it should give you what you need.

  • Yes, this issue gave me a headache. Thank you very much for your answer! – Marvin80 Jul 28 '12 at 22:13

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.