Geofield needs an map input widget that's independent from widgets found in GMaps and Openlayers. Here's my wishlist...

- Able to draw points, lines, polygons, and bounds
- Painless to set up (It just works)
- Minimal configuration
- Aware of field count. (i.e, if your field only allows for 3 items, map only draws 3 features)

UX

I'd like the controls on the widget to stay pretty simple. On the first comment of this post, there's a series of images that show a basic toggle button, which has the potential to expand to give different options. Based heavily on the dropdown buttons in the new Views UI, the button would have an on/off state that dictates whether or not the user is able to draw on the map or not. The button should default to drawing points, but expanding the button allows you to chose what type of feature you'd like to draw.

For advanced users, it's worth keeping the keyboard shortcuts from the Openlayers widget around, and have the button reflect what keystroke combo you're using.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Brandonian’s picture

UX wireframes of states for issue summary.

Brandonian’s picture

Issue summary: View changes

spelling errors.

nod_’s picture

I actually need this for a project. There is already an openlayers input widget. What's the status of this right now ?
I might be able to help.

Brandonian’s picture

Very cool, nod_! I haven't done much on the module side, but I'm probably 80% of the way there on the widget, which can be found at https://github.com/fillerwriter/Gmap-Input.

Currently, the widget is capable of rendering points, lines, and polygons in a Google map, along with returning valid GeoJSON. The main things that the widget needs to do at this point is load data properly from an input, allow for edits from the map, and general polish. Any help on that end would be appreciated.

nod_’s picture

Status: Active » Needs work

ok so i got it working but it's pretty far from the wish-list.

I copy/pasted the code from openlayer draw widget and made it work to feed wkt to geofield. It's more or less what the openlayer draw feature gives: point, line, polygon, 'freehand line' and edit ability for your shapes.

As geoPHP fails on empty collection geometry if you don't draw anything on you map, the form submit will fail and nothing'll get saved. I'm looking at how to solve that js style. (while testing, draw at least 1 thing on every map input displayed).

Of course it requires openlayers to work, and fill in the wkt hidden field with geometrycollection() and whatever you draw inside. No way geofield_map will display anything from this kind of field, you need openlayers.

I really need to look at what to remove and where I think this could be simpler. It'd be nice to figure out who should own the draw feature, the openlayers project or geofield. If There is nothing new soon I'll be posting about it in the openlayer module queue.

Don't have time to clean up my patch, will send it tomorrow.

nod_’s picture

Grrr crappy connection made me lose my text…

So, it works, multi-values too, based on openlayers functionnality, default toolbar and some unused code in the behavior class for future ui settings options.

Could be improved a lot, limit number of features. override default multi-value presentation to transform them into layers. do some PHP validation to enforce this on top of JS.

nod_’s picture

Status: Needs work » Needs review
nod_’s picture

sorry, update of the previous patch, i wasn't clearing the field on feature deletion.

Brandonian’s picture

Title: New native widget for data input » Geofield/Openlayers widget refactor
Status: Needs review » Fixed

Thanks for the patch, nod_!

I have mixed feelings about this patch. On one hand, it handles our functional problems that have been widely documented in the issue queue. It handles multiple widgets like a champ, and further improves the usability of the widget by enabling Openlayers' native edit feature control.

On the other hand, the bounds control is MIA with this patch, and we also regress back to Openlayers default controls for the edit widget. I'd prefer to move towards a control widget as outlined in http://drupal.org/node/1273802#comment-4967212.

That being said, this is a vast improvement from where we were, and will be a great base to work from to add back our bounds control. Committed, but I'm opening new tickets for bounds control and the widget control. Great work, nod_.

Also, I just noticed we hijacked the wrong issue for this discussion. D'oh! I'll also open up a new ticket for a native widget.

eiriksm’s picture

Don't know if you want this comment in this issue, but I have a request/question.

With the new input widget, points are added in addition to existing points, in comparison to earlier when it replaced the point you had set. This can be confusing for some, as you also can add multiple values for the field (meaning several maps) instead of several points on one map.

Of course you can move the point that has been set, but as far as I can see, you can not delete a point that has been set. Is this correct? I'm guessing that most users would find it confusing and strange that they have to move a point instead of just setting a new one when editing a node with a map point already set.

edit: Sorry, Just found out by looking at the code. For reference, if someone else have this question: 'Delete' button removes the point. Time to test this on my users (they are very often editing map points)

nod_’s picture

@eiriksm: i'd be interested to know what they have to say :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Sinan Erdem’s picture

Status: Closed (fixed) » Active

I am using the latest dev version of this module but İ dont see the new display style. Instead I see like the old openlayers style. Is the patch commited yet?

nod_’s picture

Status: Active » Closed (fixed)

wrong issue.

the styles come from the ol module. you have to update the image and CSS path of your map configuration to see the change.

Sinan Erdem’s picture

Status: Closed (fixed) » Active
FileSize
13.82 KB

Sorry, I couldn't express myself enough. I am seeing the new style of Openlayers (coming from the OL css). But instead I should see a dropdown similar to comment #1, right?

I am attaching what I currently see...

Is there a different location of dropdown css or something?

nod_’s picture

haha oh sorry. You can see in the middle I hijacked the issue and fixed a couple of issues with the patch for openlayers. The initial plan was to have an input widget based on google maps which wouldn't require the openlayers module.

So no, the new style as described in the first couple of posts is not available.

Brandonian has been working on it on github, I haven't had much time to give it a shot myself. Wait and see :)

Sinan Erdem’s picture

Oh now I am your accomplice right? :) I think Brandonian's proposed widget is more user-friendly. I will be waiting for it.

Brandonian’s picture

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

Moving to the next version. I think what we have now is good enough, and I'd like to wind down new development on 1.x.

drzraf’s picture

I still can't find how to select a given OL map preset for a given field instance widget.
Seems like it's possible with the Openlayers WKT field (see /node/904646 section 3) but not with Geofield, even since this patch was pushed. Am I wrong ?

[edit] finally got my OL map as available as a widget (geofield behavior checked), but still stuck on the second part of the question.

The underlying problem for me is that I already have an OL map which draws selectable features from GeoJSON.
I want my widget to allow selecting among the provided polygonal features (+ some control over hover/highlightonly). Is such a thing possible in the current shape of the geofield ?

drzraf’s picture

I think that the behaviors, when reusable, should be part of Openlayers (like a OL.Control.SelectFeature in #1440996: no ability to add custom SelectFeature)
But on the Geofield side, Drupal.behaviors.openlayers_behavior_geofield should ease their integration.
In its current shape, I can create custom behaviors in my module but can't reuse the Wkt related functions of Geofield (but if it's possible then any hints about how to do this would be appreciated)

Drupal.behaviors.openlayers_behavior_geofield should clarify the use of context, dataLayer and dataProjection variables.
The most important being that Geofield would not rely on creating its own layers (dataLayer) but allow the use of custom behaviors and layers while still doing its work at registering the Wkt related event on 'featureadded' & co.

does it make sense ?

phayes’s picture

Refactor stage one has now been committed into the 2.x branch. Please leave your feedback and comments.

Major changes are:

1. All settings are now part of widget settings, not part of behavior settings
2. multiple-values behave as expected now (woohoo!).
3. When drawing over the allowed-number of values, your oldest shape is removed.
4. num-values and allowed-shapes are now validated server-side

Still needs to be done:

1. Review how I implemented delta-handling. I think it could be better but I don't know how.
2. Doxygen
3. Support for removing single vertices
4. More intuitive removing of point features. (right now you need to awkwardly click twice)

phayes’s picture

Status: Active » Needs review
Brandonian’s picture

Made a commit with the following stability improvements.

  • Widget now handles empty values.
  • Related to above, provided sensible defaults for $settings variable in function openlayers_field_widget_form(). These defaults probably could be moved to a separate function to inform other functions what our defaults should be.

I'd like to see at least one other pair of eyes on this and/or unit tests before marking this complete. Granted, we don't currently have a good way to do js testing (QUnit project, anyone :-) ) but we should at least do server-side testing.

http://drupalcode.org/project/geofield.git/commit/03e6644

phayes’s picture

Assigned: Brandonian » phayes
Status: Needs review » Needs work
steinmb’s picture

Assigned: phayes » Unassigned
Status: Needs work » Active

Crossposting #1907914: Refactor OpenLayers widget to pull out generic methods these two issues look to me as duplicates. Unassigned phayes, perhaps other would like to step up and work on this. Not sure what needs more work?

Brandonian’s picture

Status: Active » Closed (duplicate)

Agreed, @steinmb. I think at this point, my thinking on this issue has changed, and the issue itself is woefully out of date. Marking as duplicate. Thank you for taking the time to do some issue queue pruning!

Brandonian’s picture

Issue summary: View changes

Added UX section