To edit the area polygons or shapes in open layers it is sometimes tricky to select the polygon - to get it to work, I sometimes need to click on the polygon, then on another tool, and then again on the polygon to get it to highlight and become editable. Sometimes it works after a couple tries, and sometimes I need to go back and forth many times. I have not figured out a clear pattern for what makes it selectable. I imagine it is a known issue for open layers. I have always been able to select shapes eventually, but it is very annoying not to understand how to do it consistently.

Comments

m.stenta’s picture

I've experienced the same thing... and I think the pattern is: you need to click on the "Select" icon (which is really more of a "Pan" icon, in my opinion), then select another tool, then click on the "Select" tool TWICE. It's ridiculous, I agree... haha. And it's probably a known issue in Openlayers.

I did mention it in this issue (in the Geofield module): #1350320: Openlayers 2.13 breaks ability to delete features, specifically in this comment: https://www.drupal.org/node/1350320#comment-9405459

Note: there does still seem to be a minor issue, but I'm not sure if it's related to this one. After creating a feature, I need to click on the Modify button twice before I'm able to select the feature. But it does work. If you don't click twice, though, it seems like it doesn't work. It took me a little while to realize this, and the ability to select seemed very buggy...

I'll do some searching to see if others have identified it in either the Openlayers of Geofield modules...

m.stenta’s picture

Title: editing areas polygons in open layers » Selecting features requires clicking the Modify button multiple times
Project: Farm Area » Geofield

I couldn't find any existing issues about this bug. I'm going to make this the canonical issue, and move it to the Geofield module issue queue. My guess is that it is a bug with Geofield and not with Openlayers, because it's the Geofield behavior that creates those tool icons. If it turns out to be an Openlayers issue, we can move it to that queue.

m.stenta’s picture

Update: well, I decided to start by testing the Openlayers module's "Draw Features" behavior, to see if it works properly there. My thinking is that if it works there, then it means the issue is in the Geofield behavior javascript, and not the Openlayers module itself.

So I turned off the "Geofield" behavior in my map, and turned on the "Draw Features" behavior. Naturally, this means the features I've saved in the Geofield are not shown, but I can draw new ones with the "Draw Features" behavior.

However, with the "Draw Features" behavior, I am not able to select features at all. Not even with a double-click on the icon, as I described above.

So that makes the debugging a little more complicated. It means that either a) there's an underlying bug that is breaking both behaviors, b) both features have their own individual bugs that are breaking each, or c) a combination of (a) and (b)...

Sigh. Time to dig in...

m.stenta’s picture

m.stenta’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Changing this to the 7.x-2.x branch of Geofield.

m.stenta’s picture

Well this isn't encouraging... here is one of the Openlayers 2.x examples:

"Demonstrate polygon, polyline and point creation and editing tools."
http://dev.openlayers.org/examples/editingtoolbar.html

Can't select features there either... :-/

Could this be an issue with the Openlayers JS itself??

m.stenta’s picture

On the other hand, here's one that works:

"A demonstration of the ModifyFeature control for editing vector features."
http://dev.openlayers.org/examples/modify-feature.html

m.stenta’s picture

I've decided to focus only on the Geofield behavior at this point... since that's the only one I'm worried about, and it seems that the Openlayers Draw Features behavior is broken in its own way.

New clue: if I comment out lines 31-46 (the part that defines the button for modifying features), I'm seeing the same bug happening with the remaining buttons. By commenting out those lines, the Modify button is not added, but the other controls for drawing points, lines, and polygons are. Since the "Line" button is the last to be added, it ends up as the one that is selected by default when the page loads. However, it doesn't work immediately. If you try to draw a line immediately after page load it does not draw anything. You first have to click on another feature, then back to the line, and then it works.

So it seems that on page load, one of the buttons (the last one) is selected by default, but it isn't actually activated. In order to activate it, you need to click on another one, and then back to the first one.

Note that it does NOT work to simply click the enabled button again, without clicking another button first. So there must be some code that activates/deactivates the controls ONLY WHEN another button has been selected first. This makes sense... but for some reason the initially selected control is not actually active.

caspervoogt’s picture

@m.stenta, sorry I am only now responding. I don't get email notifications of replies - not sure why not. I also have not touched Geofield in many months and have not had occasion to dig into this stuff since my last post on it.

http://dev.openlayers.org/examples/editingtoolbar.html works fine for me (Chrome/Macbook). So does http://dev.openlayers.org/examples/modify-feature.html .

"So it seems that on page load, one of the buttons (the last one) is selected by default, but it isn't actually activated. In order to activate it, you need to click on another one, and then back to the first one." I have seen this before but can no longer reproduce it. I am running Geofield "7.x-2.3+0-dev" and OpenLayers 7.x-2.0-beta11.