Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've got various vector layers on a OL map. On one layer I have a few draw controls. If I draw a polygon I can select it (the whole pop-up thing works). This also works for all the other features. Then I use the modify control to reshape the polygon. When I complete this action (with a clickout) I catch the afterfeaturemodified event and disable the modify control, re enable the selectcontrol for the map.

Now the problem occurs. The clickHandler of the selectControl cannot get the modified feature from the event. I used drawlayer.layer.getfeaturefromevent(event). The weird thing is, this does work for all the other features that er still on the map. Doing things like:


doesn't help. I use the infoWindow for a form that actually saves the modified feature, so I need this to work. Also, I can't use the modify control more then once on the same feature. Which is also very annoying from a usuability point of view. If I look at the DOM, the drawLayer still has just one feature.

I've got no idea how to solve this. Any help would be nice.

share|improve this question
It is hard to reproduce your issue because you don't share your source code. I've built a little demo in jsfiddle and it looks like all three controls (select, draw, modify) works fine. See LIVE DEMO. –  drnextgis Dec 20 '12 at 3:46
I had similar (but not exactly same) situation with DrawFeature control and point features. As ugly solution: on event handler I did setTimeout (for 100 ms, for example) for code, that selects feature. Reason - after executing callback for event, DrawFeature control had some more code to execute, that ruined things. setTimeout allowed control to finish it's job correctly. –  user1702401 Dec 20 '12 at 8:07
yeah, because of all the added extra's it is a lott of code. I'll try if I can modify your set-up to reproduce the bug –  Jeroen Dec 20 '12 at 9:31
I do think it's posible somethings goes wrong because of the enabling and disabling of the controls. I'll try this. What do you mean with 'on event handler'? Did you change the OL source to just wait a while after the afterfeaturemodified event? –  Jeroen Dec 20 '12 at 9:34
No, I didn't modify OL source. And I was using DrawFeature control and featureadded event - so it's not your case, it's just idea, that you may try out. It was something like layer.events.on({'featureadded': function() {setTimeout('function_that_does_actual_stuff();', 100) }}); –  user1702401 Dec 20 '12 at 9:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.