Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
Since the last alpha release, geofield provide a proximity filter for views.
It would be nice to have an autocomplete field for that exposed filter.
Basically the options should allow to choose what do you want to autocomplete (country, regions, city...) for the origin field.
What do you think about that ?
Regards,
Alex
Comment | File | Size | Author |
---|---|---|---|
#41 | geocoder_autocomplete-views-proximity-filter-1839204-41.patch | 2.86 KB | jantoine |
Comments
Comment #1
benjmarr CreditAttribution: benjmarr commentedGreat idea alex... would certainly use this for a Project we are working on!!
Comment #2
trebormcgood idea
Comment #3
fastangel CreditAttribution: fastangel commentedI did a patch for the integration. Now in the exposed filter (geocoder) you can select geocoder autcomplete.
Comment #4
fastangel CreditAttribution: fastangel commentedComment #5
fastangel CreditAttribution: fastangel commentedSorry I did bad the patch. I attach new patch.
Comment #6
fastangel CreditAttribution: fastangel commentedSorry a new patch again :(
Comment #7
benjmarr CreditAttribution: benjmarr commentedHi There,
Tried Patching but it failed at one of the points-
Last login: Tue Sep 10 17:15:07 on console
~ $ cd Sites/geocoder_autocomplete
geocoder_autocomplete $ patch -p1 < geocoder_autocomplete-integration_geocoder_views.patch
patching file geocoder_autocomplete.info
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file geocoder_autocomplete.info.rej
patching file geocoder_autocomplete.module
Hunk #1 succeeded at 60 with fuzz 2 (offset -27 lines).
patching file views/proximity_plugins/geofieldProximityGeocoderAutocomplete.inc
geocoder_autocomplete $
also where does it give you the option in views?
Comment #8
fastangel CreditAttribution: fastangel commentedThe patch work fine for me with the branch 7.x-1.x. The patch implements a hook of geocoder. Then when you select a proximity filter you can select the origin point. In the origin point you have a new options. Autcomplete geocoder.
Regards.
Comment #9
edivad CreditAttribution: edivad commentedIt work also for me.
Geofield branch 2.X and geocoder 1.X.
Thanks.
Comment #10
joco_sp CreditAttribution: joco_sp commentedwich worked for you?
I tried #6, but I can't apply it. It gave me the error: Hunk #1 FAILED at 1.
and saved the rejects in a file.
the rejects are these:
***************
*** 1,3 ****
name = Geocoder Autocomplete
description = Provides a text field widget with autocomplete via the Google Geocoding API.
core = 7.x
--- 1,4 ----
name = Geocoder Autocomplete
description = Provides a text field widget with autocomplete via the Google Geocoding API.
core = 7.x
+ files[] = views/proximity_plugins/geofieldProximityGeocoderAutocomplete.inc
Comment #11
MXTI can confirm that patch provided in #6 works well for me.
I'm using Geofield branch 2.X and geocoder 1.X.
BUT PAY ATTENTION PLEASE: patch in #6 does not apply: I had to manually applying it.
Thank you very much: I hope this can be committed soon by maintainers
Comment #12
MXTHide wrong patches, and marked as RTBTC because patch works correctly, although it must be manually applied
Comment #13
svanou CreditAttribution: svanou commentedHi all,
I cannot get it to work on my exposed filter. Can someone explain how to apply manually ?
Thanks, Sylvain
Comment #14
svanou CreditAttribution: svanou commentedcan someone point me in the right direction ?
Thanks!
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedThe solution works for me when creating a node based view, on a search index view I can't seem to use this great feature.
If I would want to implement this on a indexed node from the search index, would this be possible and could you point me to information regarding the hook I'd have to use to get this to work?
Basically I'm looking into getting a search page to allow the user to enter a center and radius but still have facets available to filter further.
The whole thing should be powered by SOLR through the search api. Unfortunately I have seen so many modules and patches that I am wondering if I shouldn't be looking into custom code.
The search page allows for a radius to be hardcoded from a center point but I want them to be exposed like this module does in views.
Comment #16
narkoff CreditAttribution: narkoff commentedI have same issue as #15. Manually apply patch and create standard "Content" view that hits the Drupal database, and the autocomplete works on the Geofield field type.
However, if a Solr Search API view is created, the same Geofield field that is now indexed does not expose the "Source of Origin Point" drop down. So, "Geocoder Autocomplete" can not be selected and there's no autocomplete functionality.
My Solr Search API view works just fine directly typing into this Geofield proximity filter and using Geocoder to convert the entry to lat/lon coordinates. I am simply looking for a (Google?) autocomplete function for the text entry only. Any ideas on how to accomplish this?
Comment #17
pinkonomy CreditAttribution: pinkonomy commentedCan this work for Search api location to replace the address field with the Geo autocomplete?
thanks
Comment #18
pinkonomy CreditAttribution: pinkonomy commentedAny news on this?Is there any way to achieve this?
Comment #19
bluesman2014 CreditAttribution: bluesman2014 commentedI applied patch #6 but I can't get the Geo autocomplete to work. If I select 'Geocoder Autocomplete' as the Source of Origin Point in my exposed filter, it throws an AJAX HTTP 500 error at me:
And the error log tells me:
PHP Fatal error: Call to a member function value_validate() on a non-object in /home/***/public_html/sites/all/modules/geofield/views/handlers/geofield_handler_filter.inc on line 194
Has anyone else come across this?
Comment #20
capfive CreditAttribution: capfive commentedpatch applied fine for me on dev version, working perfectly! thanks so much!
Comment #21
Anonymous (not verified) CreditAttribution: Anonymous commented@bluesman2014
I have the same error, did you figured this out?
I tried the same steps as you did, my ajax error code is 200 but the php log error is on the same line 197.
@capfive
can you elaborate how you got this working?
Comment #22
Pequi-eu CreditAttribution: Pequi-eu commented@bluesman2014
@pintoflager
Same Ajax Error code 500. Did you managed to fix it?
Thanks a lot!
Comment #23
imavers CreditAttribution: imavers commentedI've fixed a small issue in patch #6. There were a couple of params missing in
Comment #24
Pequi-eu CreditAttribution: Pequi-eu commentedDon't know what I did but patch is now working with no AJAX Error. I will try to investigate.
Comment #25
jarjar CreditAttribution: jarjar commented#23 works for me. Thanks for the patch !
Comment #26
alves76 CreditAttribution: alves76 commented@Pequi-eu Have you figured out how to fix #19 ajax error?
Comment #27
alves76 CreditAttribution: alves76 commentedComment #28
alves76 CreditAttribution: alves76 commentedComment #29
MXT#23 works for me also.
Please commit
Comment #30
MXTIt seems that
patch #23 does not work with Drupal version > 7.38
This probably due to autocomplete API changes in 7.39, see "known issue" in https://www.drupal.org/drupal-7.39-release-notes
Some other modules have already adapted their autocomplete logic. For reference:
Also always from https://www.drupal.org/drupal-7.39-release-notes:
Comment #31
Pequi-eu CreditAttribution: Pequi-eu commented@alves76
I didn't understand what happened but I'm using 7.41 and #23 was not working at the beginning and then worked. I didn't have enough time to search and understand.
Comment #32
slaurent CreditAttribution: slaurent commentedJust tried this module with the patch and encountered the same error (ajax http 200, php fatal error detailed in #19). Any news on how to fix it? I'm using 7.41. Maybe it depends on Geofield version as well?
Comment #33
Maximus8 CreditAttribution: Maximus8 commented@slaurent
i read through the functions which where called by my view and they showed me that the Views Plugin was simply not in the right folder. I had to create a folder proximity_plugins in the views folder of geocoder_autocomplete and move the .inc file there. Now i dont have any AJAX error...maybe its also the solution in your cases!
But besides that i can choose now the geocoder autocomplete as source of origin point, i dont get any additional features. Am i missing something? i dont get a autocomplete Box, its still the normal geofield field...everything is just like before.
EDIT: I have figured out, that regarding the html classes the autocomplete_path attribute is not added by the after_build function. But altering other attributes like "required" works perfectly...I also tried to add the autocomplete_path on a custom form via the form api and it works! So theres just a problem in the geofield field widget with adding this behaviour. I have no idea what, but something is blocking the behaviour to be attached.
EDIT2: Regarding the questions in my contact formular, the description was not that clear, so the path where the .inc file should be is:
/sites/all/modules/geocoder_autocomplete/views/proximity_plugins/geofieldProximityGeocoderAutocomplete.inc
Comment #34
cp4w CreditAttribution: cp4w commentedHello,
I applied the patch (#23). But the '#autocomplete_path' was not raised while entering text in the field.
But indeed (I've read this earlier in this discussion), since Drupal 7.39, the Autocomplete Ajax calls have to be validated first.
The patch adds this:
function geocoder_autocomplete_add_autocomplete_form($element) {
$element['origin']['#autocomplete_path'] = 'geocoder/autocomplete';
return $element;
}
Instead, the following is sovling the problem to me:
function geocoder_autocomplete_add_autocomplete_form($element) {
$element['origin']['#autocomplete_path'] = 'geocoder/autocomplete';
if (function_exists('form_process_autocomplete')) {
$element['origin'] = form_process_autocomplete($element['origin']);
}
return $element;
}
I've no much time to create a new patch... I'm just going to hack the contrib module (baaaaad I know.... :-) ). If someone wants to create a new patch... be my guest.
Comment #35
MXTYES!, solution provided by cp4w in #34 seems to resolve the issue.
Thank you!
Waiting for a patch now :)
Comment #36
MXTOk I made a cumulative patch including #34: all works right for me now.
Please review it.
(patch created with
git format-patch
: should be applied withgit am <patch-name>
)Thank you
Comment #37
EdPhillis CreditAttribution: EdPhillis commentedCould someone tell me how you apply one patch file in two different places??
Comment #38
donquixote CreditAttribution: donquixote as a volunteer commentedCode:
Just saying, there are whitespace errors.
Functionality:
I am trying this with Search API / Facet API, and Geofield with LatLong Pair (indexed).
So far I don't see how to enable the autocomplete for this.
The only options I see are the "Input method": Either "Geocoder input" or "Raw input".
EDIT:
This said, I also don't see how to apply any of the other proximity handlers from geofield_proximity_views_handlers().
EDIT:
I just hacked it myself with hook_form_views_exposed_form_alter(). Not really a solution for this issue, obviously.
Comment #39
GiorgosK#36 patch did not apply cleanly with "git apply -v patchname.patch"
I applied it by hand which was not too difficult
but still enabling and using the view was bringing back a WSOD with no log messages in the system
I had no time to debug since it was extra functionality which can wait
Comment #40
kateryna16f CreditAttribution: kateryna16f commentedHello,
patch from #36 almost working for me.
In the view preview mode the google addresses appears when I'm typing in the field.
In the frontend the autocomplete doesn't work. Any ideas?
Comment #41
jantoine CreditAttribution: jantoine as a volunteer commentedThe attached patch fixes all coding standards issues with the patch from #36.
Note: The patch fails to apply to releases provided by Drupal, and that's OK. Patches are meant to be applied to the git repository, not to releases.
The patch fails to apply to releases due to a conflict with changes made by this patch and those made by Drupal's packaging system to the geocoder_autocomplete.info file. To work around this, remove and manually apply the first hunk in the patch to the geocoder_autocomplete.info file. The remainder of the patch should apply to the 1.1 or 1.x releases just fine.
If you find that autocomplete is working during views configuration but not in the frontend, this is caused due to lack of permission. The 'Access Geocoder Autocomplete' permission needs to be given to any roles you wish to be able to use the feature.
Comment #42
nessunluogo CreditAttribution: nessunluogo as a volunteer commentedAny luck to make this work with Search API?
PS: when I apply the patch the GeofieldProximityGeocoderAutocomplete.inc is added into views/proximity_plugins but into ip_geoloc module folder instead of geocoder_autocomplete. Moving the file in the right place makes it work perfectly. Anyone is getting this issue?
Comment #43
steffl CreditAttribution: steffl commented#41 is working for me, have two questions on that:
1)
The exposed filter is showing up in a views page but not in a views block. Is this normal or am i missing something?
2)
Autocomplete shows only 1 suggestion, normally it makes sense to show more. If the visitor only typed in 3 characters of the city, the one result showing up is mostly not the city the visitor is looking for. How can I achieve to show up 3 or 5 results?
Comment #44
benjmarr CreditAttribution: benjmarr commentedUsing patch #41.
Digging up an old issue but seem to be having some trouble. The filter works as in I can type in an address (google formatted) and return correct results but I cannot get the autocomplete to show results on both admin and front end. No errors that I can see in console or log.
Comment #45
Summit CreditAttribution: Summit commentedHi, has anybody this working please?
Thanks for your reply in advance.
greetings, Martijn
Comment #46
danzVP06 CreditAttribution: danzVP06 commentedHi,
I applied the patch number #41 but still not getting autocomplete, but then I found and applied this patch which gets the api key: https://www.drupal.org/project/geocoder/issues/2955244#comment-12807038
I can now see the autocomplete, it's only showing one result. but it's working on views page and views block exposed filter.
Hope this helps anybody
Comment #47
Summit CreditAttribution: Summit commentedHi, Can you may be show your view on which it is working please? thanks in advance!. Greetings, Martijn