Closed (fixed)
Project:
Geofield
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Jun 2012 at 01:11 UTC
Updated:
30 Aug 2013 at 23:41 UTC
Jump to comment: Most recent file
Comments
Comment #1
nedjoHere's a beginning, along the lines outlined in "proposed resolution". It's a complex issue and there are several possible approaches--not sure this is the best, but thought I'd sketch something in. Not currently functional--geocoding in a validate callback doesn't set the rendered form values. Ideas or improvements on that issue or on the overall approach welcome.
Comment #2
nedjoShould this be on 7.x-2.x? Or wait until the widget-revamp branch stabilizes?
Sketched in some relevant assumptions in #1393246-22: Interactive geocoding widget.
Comment #3
nedjoSome minor fixes (output an element wrapper div using #prefix and #suffix, change button from 'submit' to 'button'). However, still not outputting the geocoded values in the returned form element.
Comment #4
Brandonian commentedTagging for map sprint on Friday, in case I don't make time to look at this before. Based on the summary, this looks like it's going to be a great addition to Geofield.
@nedjo, this should be based on the 7.x-2.x branch. I merged the two branches a few weeks ago, and haven't done a great job of cleaning up my extra branches in the public repo.
Comment #5
nedjoHere's a patch on the 2.x branch.
The patch is now working thanks to a tip about working with AJAX submissions. Not sure if that's the recommended approach--unsetting an input, seems like a quirky workaround. Could use review by someone familiar with D7 AJAX forms.
The patch includes a couple of unrelated fixes I needed to do to get it working: removing a duplicate widget declaration from
geofield_field_widget_info()and returning a form fromopenlayers_field_widget_settings_form(). I'll pull those into a separate patch when I get a chance.This patch still requires the patch at #1627906: Enable other modules to use geocoding field processing.
Comment #6
nedjoReroll after recent changes. Also improve #states handling.
Requires #1637476: Geofield widget does not show and "Store each simple feature as a separate field." doesnt work and #1637904: Remove duplicate geofield_openlayers widget (the first of which presumably will require manual patching, since it changes contiguous lines).
Comment #7
nedjoAttaching a screenshot of the widget when configured to use geocoder.
When the button is clicked, just the widget part of the form is returned via AJAX, including a point geocoded from the address (if one was entered).
However, if there's an error on the form (e.g., title field is empty), that error message is returned and no geocoding is done. Need to look into the code more closely to see how to avoid triggering validation errors.
Comment #7.0
nedjoUpdate summary.
Comment #8
nedjoHere's a considerably improved patch based on study of core's add_more field widget. Now doesn't trigger validation errors.
Comment #9
nedjoReviewing with Patrick.
Needs testing with multiple values.
This line could use a comment. Also, determine if both fields need to be excluded or only the geocoder field.
Needs code comment.
Also, add a message if no geocoder results returned.
This looks like it will fail if e.g. the geofield is nested in a fieldset. Find #parents and use drupal_array_get_nested_value().
Comment #10
phayes commented@nedjo,
I've updated geocoder_widget_get_field_value in geocoder, so now you can pass an array of deltas instead of the whole entity.
Comment #11
nedjoThanks Patrick. Here's an updated patch addressing most of the issues noted in #9.
Changes:
Remaining issues:
Comment #11.0
nedjoReference field_form_set_state().
Comment #12
nedjoFixed the visible weight issue from #11 by unsetting the weight prior to returning the form element (same as is done in addressfield module with the address widget).
Changed "Geocode from [field label] field" to "Find using [field label] field" to be consistent with the labelling introduced in #1637108: Lat/Lon FormAPI: Add button to force geocode.
Successfully tested with:
All identified issues now addressed so this is ready for review.
Comment #12.0
nedjoUpdate remaining tasks.
Comment #13
henryblyth commentedThe patch in #12 does not work for me. It is the first patch I have tried.
I can set everything up, and the AJAX call goes through and returns a map, with an ID increment. However, there is no new data on the map. Manually added points persist, but no point from addressfield data is added. Tested on both a clean content type setup and using a current addressfield that another field geocodes and displays correctly on an openlayers map.
Using all the latest versions:
I can't wait for this to appear in a stable release! It will be extremely helpful for us.
Regards,
Henry Blyth
Oxfordshire County Council
Comment #14
nedjo@henryblyth: thanks for testing!
There seems to be a problem with the geocoder dev release--it doesn't contain the latest code. Please try with a git clone of the geocoder 7.x-1.x branch. Please also apply the latest patches from the issues linked in the "Remaining tasks" section of this issue's summary.
Comment #15
phayes commentedNejdo,
I've completed phase#1 of refactoring the openlayers widget. Please see: #1273802: Geofield/Openlayers widget refactor
I would love your commentary, especially around how I handled multiple-deltas. It works, but I feel it's pretty hacky, and would appreciate any insights or recommendations.
Comment #16
robcarrI'm a bit confused regarding comments #14 and #15:
Comment #17
phayes commentedHi arggh,
No not yet, just laying some groundwork. I'll be taking a crack at applying the patch this week
Comment #18
leramulina commentedSubscribe
Comment #19
phayes commentedI've committed this. Worked pretty much right out of the box with only minor changes. Thanks Nedjo.
Comment #20
steinmb commentedGreat work phayes and nedjo. Is the only follow up task remaining? #1637904: Remove duplicate geofield_openlayers widget
Comment #21
phayes commentedYup,
There's that, cleaning up doxygen, and updating documentation.
Comment #22
henryblyth commentedRolled it into a local-copy of a production site and it worked nicely.
Thanks very much guys!
Comment #24
osopolarSee follow-up issue for client side geocoding:
#2078255: Add optional client side geocoding to map input widget.
Comment #24.0
osopolarRemove completed tasks.