I'm using the map widget to insert location information. Setting and dragging markers works. How do i remove markers from the map?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nod_’s picture

click the edit feature (the leftmost button), select your feature and hit delete :)

Anonymous’s picture

This closes the overlay (Chrome on Mac).

nod_’s picture

Looks like you found a bug in overlay. Try another browser. Works for me in FF & Chrome windows.

Anonymous’s picture

Status: Active » Closed (works as designed)

Backspace != Del
It works as described.
Thanks

Leander Bindewald’s picture

to save others the 20 embarrassing min it took me to figure it out:
delete on mac = fn+backspace
cheers

Patroclas’s picture

This does not work for me in FF or Chrome - it just exits the edit screen.

phayes’s picture

Assigned: Unassigned » phayes
Status: Closed (works as designed) » Active

Re-opening as it sounds like there are some lingering issues. Assigning to me so I can investigate.

nod_’s picture

@patroclas can, you be more specific about the version of browser you're using ? Works for me on win and nux.

Patroclas’s picture

I am working from the dev version now and it does work OK with the DEL key on Windows 7. Not sure if it was my settings or not.

phayes’s picture

Status: Active » Closed (works as designed)

Thanks for the follow-up @Patroclas. Closing this ticket. Feel free to re-open if there are remaining issues.

AaronBauman’s picture

Status: Closed (works as designed) » Active

Geofield 7.x-1.x-dev and geofield 7.x-2.x-dev
OpenLayers 7.x-2.x-dev

none of these keys or key combos work on osx 10.8.4 with the following browsers
Safari 6.0.5
Chrome 29.0.1547
Firefox 22
Firefox 23:

del
backspace
command-del
command-backspace
opt-del
opt-backspace
ctrl-del
ctrl-backspace
shift-del
shift-backspace

pressing "del", along with any modifier key, results in the following javascript error (or similar) on the console:

TypeError: 'undefined' is not an object (evaluating 'this.selectControl.unselectAll')
openlayers_behavior_geofield.js:40

i do not have a "fn" key.

thtas’s picture

Issue summary: View changes

I fixed this by forcing openlayers.module to use openlayers 2.12.

The update to 2.13 means the selectControl method doesn't exist on that class anymore.
See https://github.com/openlayers/openlayers/blob/master/notes/2.13.md#contr...

So the behaviour js needs updating to be compatible with the latest openlayers.

Ericmaster’s picture

Here is a patch I just created to fix this if you still want to use version 2.13.

Ericmaster’s picture

Status: Active » Needs review
garbo’s picture

Thanks EricMaster,

Your patch works halfway. The point are removed after saving the node. But they display visible while editing until the savebutton is hit.

gregoryshearer’s picture

Is there going to be any additional followup on this issue? I can also confirm the issue described in #11. I get a similar javascript error in the console upon pressing the delete key. I can also confirm downgrading the OpenLayers library to 2.12 fixes this issue. (I installed it locally under sites/all/libraries and changed the settings for OpenLayers module in the gui.)

I can also confirm that the recent patch works for the most part. You can select the item and hit Delete it does disappear from the display in the edit screen, but if you then click a different point (say you want to delete two points) the one you just deleted reappears. It cannot be selected or deleted again, I think because it is actually gone. When you save the node it is gone from the display and if you edit the node again it is gone.

Thanks for the module and the patch!

Geofield 7.x-2.1 and OpenLayers 7.x-2.0-beta9

tdurocher’s picture

I have the same problem. All my modules and layers have been downloaded in the last few weeks. This may be a duplicate of https://www.drupal.org/node/2320353, which was also just reported recently. I actually think this issue here is about two different problems that sound similar - the first from 3 years ago, the second since OL 2.13.

tdurocher’s picture

Actually I have now succeeded in doing this. The trick, for me anyway, is to click on the marker first to select it. It will not give any indication that it is selected but when you hit the delete key fn-delete on mac. I'm not using the line or polygon so not sure if that works, but the points to (usually). I know - I wasted a lot of time on this too. Kind of frustrating for such a simple problem.

boabjohn’s picture

FileSize
126.11 KB

G'Day all,

After yet another hour of reading threads on this issue it seems like I have no idea how it is "supposed to work" on either Mac or PC.

The basic problem seems to be the lack of a clear [edit] mode that is signalled to the user through the UI.
People are confused:
https://www.drupal.org/node/2320353
https://www.drupal.org/node/1586442
https://www.drupal.org/node/1773906

There is the complexity of people who need the map to allow only one feature (respect limits defined in the field config); there is the problem of how to edit a point (drag) vs delete vs edit/delete a vertice in a polygon.

And there is the confusion of storing each feature as a separate field vs storing them as a collection (eg, it seems possible to set Store as a collection=true AND limit features to 1...does that mean 1 collection of multiple points is allowed?)

Anyway, those are some of the twisty bits I've found in the general area of HOW TO EDIT MARKERS.

Now specifically, I just don't get the interface. In the screenshot, you see the point and poly tools are black (means "selected", or not?) and the pan cursor is grey (means inactive? No idea...yet)

USECASE: Delete the polygon. What do I do?

1: Simply "click on the feature and hit delete"

  • Click on the feature: there is no change of state to show it is selected.
  • Hit delete: nothing happens

2: Choose the pan button, then click on the feature and hit delete

  • (as at 1)

3: Choose the polygon tool, click on the feature

  • Polygon tool goes grey (aha! that must mean it is selected, not inactive...weird)
  • Cursor changes to point/dot
  • Click on the feature: starts a NEW FEATURE
  • Click back on the pan tool (why would I do that? it's a pan tool...not a selector, right??)
  • Now the polygons can be highlighted and their shapes can be edited (drag the vertices around)
  • However, even when the polygon is shown as selected (ie vertices can be dragged), hitting the delete key does nothing.

4: Add new point, try to delete

  • Click on point tool (goes grey...yeah right, it's "active")
  • Click on the map, point is added.
  • Click on pan tool, try to click on point. It does not show any sign of being selected, however it can be dragged
  • So I know I have it under my control. Now hit delete. Nothing happens.

Acck.

My system: Win7/FFox latest. Widget is set to allow shape modification, store each feature as separate field, and unlimited values. Geofield 7.x-2.3 (I didn't want to hijack this issue version), and OpenLayers 7.x-2.0 beta11 on top of OL2.13 from external source)

I'm quite happy to accept that I don't "get it"...but it would be much easier to figure out if there were a clear "How-to edit features" so at least I would know if this is a collection of bugs, poor UI, or just my ignorance.

As a proposition, if someone would be so kind as to just explain what is supposed to happen that would be great. I'll make a screencast and some notes to go with the docos.

Thanks in advance!

m.stenta’s picture

@amorsent and I spent some time digging into this issue today.

It is definitely the issue described in #12: The new version of Openlayers (2.13) removed the selectControl method from the ModifyFeature class.

The release notes for Openlayers 2.13 explain how to fix it:

... The most noticeable change is that it has no selectControl member any more. Users who previously relied on this built-in SelectFeature control will now have to create both a SelectFeature and a ModifyFeature control and configure the ModifyFeature control with standalone: true. To get features selected, call the selectFeature method e.g. from a featureselected listener on the vector layer. ...

It seems that is what @Ericmaster was doing in his patch in #13. However, I think the release notes are a little misleading in this case, and it isn't necessary to do all of that.

Attached is a patch that simply changes this.selectControl.unselectAll(); to this.unselectFeature();.

The unselectFeature() actually seems like a better choice than what was there originally... because it isn't unselecting everything... just the feature in the current layer. In practice, this is probably always the same thing, but using this.unselectFeature() feels more specific, and therefore cleaner.

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...

@boabjohn: Digging into the geofield behavior JS shined some light on the way this is meant to work. The behavior adds the four buttons: Polygon, Point, Line, and Modify. The Modify button uses the pan icon, which is confusing, but looking at the icon set that the OpenLayers module includes, it makes sense why it was chosen... there aren't many choices (http://cgit.drupalcode.org/openlayers/plain/themes/default_dark/img/edit...). Perhaps a new icon should be added that is a little more clear that it is for modifying features. "Panning" is done simply by clicking and dragging maps, regardless of which button control is selected, so using a "pan" icon is misleading.

Simple fix! Please test and change to "Reviewed and Tested by the Community" so it can be committed!

m.stenta’s picture

Version: 7.x-1.0-beta2 » 7.x-2.x-dev
Category: Support request » Bug report
Priority: Normal » Major

Oh yea, this needs to be a Bug Request... and it's pretty important, I would say... and it's in the latest 7.x-2.x branch.

m.stenta’s picture

Title: Howto remove Markers/Points » Openlayers 2.13 breaks ability to delete features

Changing title to reflect the issue that everyone here is referring to, as far as I can tell.

boabjohn’s picture

Fantastic! I will be testing this shortly...thank you indeed.
And: did you mean to imply that we could propose a new icon for use instead of the pan tool? I think even the pencil (without the +) would be a great UI improvement. The pencil could also be mirrored right-left to give it a bit more distinction from the current Add Feature pencil.

m.stenta’s picture

Yea, that's what I was thinking: add a new icon for "modify feature" button. A pencil would work, but I don't think there should be two pencils in the icon set... even with a "+" on one of them for distinction, I think it would be confusing. The current "pencil w/ plus" icon is used for adding POINTS to the map. Maybe there's a better icon for that? Other than a pencil with a plus? Perhaps just a dot?

If this solves the issue for you, please mark as "Reviewed and Tested by the Community" so we can get it committed!

caspervoogt’s picture

@boabjohn, your step-by-step is a useful illustration of the issue. I found that I could not move / select a point except following this order;

1. click the 'add point' tool (looks like a pencil)
2. click the pan tool
3. click a point. Now I can drag it.
4. click Delete. Nothing happens. Well, this happened though: "Uncaught TypeError: Cannot read property 'unselectAll' of undefined".

I applied the patch from #20 and that solved it. Now the pan tool starts off looking activated, which led me to think I should be able to directly select a point and hit Delete. Not the case;

Now all I need to do is:

1. click the 'add point' tool
2. click the pan tool
3. click a point (now I can drag it)
4. click Delete

So basically the Pan tool starts off looking active, but to get the Delete function active I have to click Pencil then Pan, on Chrome/Windows 7 anyway.

Good fix!

m.stenta’s picture

@plethoradesign: I created a separate issue for the clicking issue: #2397361: Selecting features requires clicking the Modify button multiple times

Can you read through that and confirm? Let's continue work in that issue thread.

I think this one is good to go, if you confirm that the delete bug is fixed by my patch. Want to set this to "Reviewed and tested ny the community"? It would be nice to get it committed...

SidneyGijzen’s picture

Confirming that the patch from #20 works with Geofield 7.x-2.3 and OpenLayer 7.x-2.0-beta11 (OL 2.13). Thanks m.stenta!

rutzmoser’s picture

Also confirming that #20 works using slightly older versions of Geofield 7.x-1.2 and Openlayers 7.x-2.0-beta9 (OL 2.13)

fonant’s picture

Confiming that patch #20 works here to allow polygons to be deleted.

Geofield 7.x-2.3
Openlayers 7.x-2.0-beta11
Openlayers library version 2.13