The attached patch creates a new display formatter, "Geocode from another field with option to manually select coordinates." On the field settings page, you can select from any of the geofield formatters (Lat/Lon, WKT, HTML5, etc). When displaying the field widget on the entity edit page, there will be a little checkbox, "Manually select fields". Checking the field will display the appropriate widget fields.
Caveats/things to fix:
- Only works with geofield module (no support for location or other modules because I didn't need it).
- Only supports single-delta fields. If you have multiple deltas it will break.
- If the Manual checkbox is checked, the geofield "source" value will be "manual". This was the easiest way to store this data without having to alter the table structure. Not sure if this will break compatibility with some of the formatters or break some standards.
Tested with a node and a user with an addressfield and geofield with Lat/Lon selected as the manual entry.
Comments
Comment #1
rudetrue commentedI've applied this patch and it looks great, however when I go to the edit page, and check the Manual Entry box, the incorrect widget is attempting to display, but is blank. I want to make this work with the Leaflet Widget for Geofield module. That way the user can check the box and use the map to set the marker. Any help would be appreciated!
I've went through the code but am not sure what is missing/incorrect. The hooks all seem correct when I read the documentation..
Comment #2
rudetrue commentedI've attached a screenshot of the issue. The field is an address, maybe that's why it keeps trying to show that widget rather than the one I choose in the dropdown?
Comment #3
Anonymous (not verified) commented+1 for this patch. It's awesome.
Comment #4
nurulshakina commentedthis patch is awesome. Great job! However, i am getting this error after applied the patch.
"Notice: Undefined offset: 0 in geocoder_field_attach_presave() (line 229 of C:\xampp\htdocs\examplesites\sites\all\modules\geocoder\geocoder.widget.inc)"
i am really appreciate if anyone could help me with this. thanks
Comment #5
adel-by commentedFirst, thanks for this patch.
i made a module out of your code that fits my needs.
changed the way you pass "source" to the hook_field_attach_presave i'm using drupal_static in stead.
this fixes the notice in #4
here's the module :
Comment #6
mtoscano commentedThis feature it is very interesting and a step forward to fix possible geocoding errors, thanks.
I installed the module but nothing happens. I mean I expect to see an additional widget to use for manually entry, am I missing something?
Any help it is really appreciated.
Comment #7
nurulshakina commentedHi,
Thanks, #5 really helps me. I managed to get work perfectly using localhost on my laptop. However, when I tried to deploy on the server, the browser went blank. It was so horrifying. I checked on my log my file it tells me that 'call time pass by reference has been removed by geocoder.widget.inc on line 185'. Is it possible it happened because of PHP version?
I managed to run #5 module smoothly on the server. THANKS CHIKIPI! Bless you!
Regards
Comment #8
iaminawe commentedI get the same result as @mato - I make a nodule out of the code in #5, enable it, clear caches and dont see any change to the geofield field?
Am I looking in the correct place. Any insight would b helpful.
Thanks
Comment #9
iaminawe commentedThe module solution did not work for me but the patch worked correctly after removing the & symbols from geocoder.widget.inc on line 185 - and I can leave out the address and correct a point by manually entering in the long/lat value- Thanks for this!
Comment #10
fietserwinIf you make a module out of it:
- Name the module geocoder_plus, ie. create files geocoder_plus.info and geocoder_plus.module.
- geocoder_plus.info should contain:
- geocoder_plus.module should contain the above code.
- Enable the module.
- Go to your content type,tab manage fields: admin/structure/types/manage/{your-content-type}/fields.
- Change the field widget of the geofield to "Geocode from another field with option to manually enter lat/lon".
- In the field (widget) settings, select the "Widget to use for manually entry" and save the settings.
You're done.
Comment #11
rafalenden commentedI think this functionality is "must have" and should be included in Geocoder module itself.
Comment #12
simon georges commentedDoes the patch works properly? Patch applies cleanly on current -dev version, so it could be integrated rather quickly if it is the case.
Comment #13
kenfordesign commentedI have created a new custom module with #5. Works as expected. Thanks!
Comment #14
joelpittetHere's an update of the patch in #0
There was a call time by reference failure, a typo some coding standards fixes and a some other fixes.
Comment #15
joelpittetMinor notice variable didn't exist.
Also my patch above wasn't relative, sorry.
Here's a screenshot but there is an issue with double wrapping fieldset at the moment.

Comment #16
joelpittetAh that's easy to fix, just use container type;)
Anyways I think this patch may need a bit of love and clean-up but it seems to do the trick in a quick test run.
Comment #17
joelpittetWas this meant to be commented out in the original patch?
This is pretty cool, I wonder if it's possible to just do this with all the field types and put it on the regular geocoder widget?
This feels a bit sketchy...
There must be a better way to get the field definition?
Manual checkbox disappeared after the first save and there was a warning about not being able to loop through element_children()...
Comment #18
mtoscano commentedThe HTML5 geolocation is included in the Lat/Lon widget (bad idea BTW), but if I select the Lat/Lon widget and the fallback option the HTML5 option is not there.
So it is impossible to have the HTML5 gelocation as the fallback option.
Comment #19
joelpittet@mato Want to try your hand at pushing this patch forward a bit?
Comment #20
pol