The attached patch adds a "Geocode Origin, with Autocomplete" Geofield Proximity Source (for Exposed Filter) for 2.x version,
integrating with the Geofield Geofield Proximity View (Field, Filter and Sort) Handlers System

Comments

itamair created an issue. See original summary.

itamair’s picture

Please test and review ...

itamair’s picture

Status: Active » Needs review

  • itamair committed f078647 on 8.x-2.x
    Issue #3088801 by itamair: "Geocode Origin, with Autocomplete" Geofield...
itamair’s picture

Committed to dev, this will be part of the next release.

itamair’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

hevr’s picture

Version: 8.x-2.3 » 8.x-3.0-beta2
Category: Task » Bug report

Hello itamair,

thank you for this implementation! Basically the autocompletion is working for me and very useful. I just can't pass geocoder specific options.

I'm not sure if you're still working on it. In the view field config the "Geocoder fine Settings" > "Geocoder Control Specific Options" are not working. The options passed during every request are corrupted:

http://localhost/geocoder/api/geocode?address=berlin&geocoder=openstreetmap&0=%7B&1=%22&2=g&3=o&4=o&5=g&6=l&7=e&8=m&9=a&10=p&11=s&12=%22&13=%3A&14=%7B&15=%22&16=l&17=o&18=c&19=a&20=l&21=e&22=%22&23=%3A&24=%22&25=i&26=t&27=%22&28=%2C&29=%22&30=r&31=e&32=g&33=i&34=o&35=n&36=%22&37=%3A&38=%22&39=i&40=t&41=%22&42=%7D&43=%2C&44=%22&45=n&46=o&47=m&48=i&49=n&50=a&51=t&52=i&53=m&54=%22&55=%3A&56=%7B&57=%22&58=l&59=o&60=c&61=a&62=l&63=e&64=%22&65=%3A&66=%22&67=i&68=t&69=%22&70=%7D&71=%7D

web/modules/contrib/geocoder/js/geocoder.drupal.js:23 should contain a JSON.parse(options)
web/modules/contrib/geocoder/js/geocoder.drupal.js:13 should contain only the function call query_url_serialize(v, k) :

then the data are passed in a more valid format:
http://localhost/geocoder/api/geocode?address=berlin&geocoder=openstreetmap&googlemaps%5Blocale%5D=it&googlemaps%5Bregion%5D=it&nominatim%5Blocale%5D=it
http://localhost/geocoder/api/geocode?address=berlin&geocoder=openstreetmap&googlemaps[locale]=it&googlemaps[region]=it&nominatim[locale]=it

In web/modules/contrib/geocoder/src/Controller/GeocoderApiEnpoints.php:91 you're accessing the options argument, but this is not set, see URL structure above. $geocoders_configs is also empty.

And one last note: GeocoderInterface::geocode(string $data, array $providers) has no $options argument.

I'm not providing a patch as I'm not sure how you would like to proceed accessing the options or passing the options to the geocoding plugin, which is an architectural decision. It would be nice if you could have a look at it.

thanks a lot!

itamair’s picture

Status: Closed (fixed) » Needs work

thanks @hevr ... I reopened this and will take a look asap to what you reported in your last comment

  • itamair committed 6430a4e on 8.x-2.x
    #3088801 "Geocode Origin, with Autocomplete" Geofield Proximity Source...
itamair’s picture

Version: 8.x-3.0-beta2 » 8.x-2.x-dev
Status: Needs work » Fixed

@hevr ... I further checked and tested and it seems that you made some (may be even a lot) of confusion here ...
This issue regards the 2.x branch of the module, and for whet refers to the "Geocoder Control Specific Options" textarea input it is clearly stated (as a underline note under it) that:

This settings would override general Geocoder Providers options. (Note: This would work only for Geocoder 2.x branch/version.)

(it is due to the specific way of implementing the Geocoder providers as configurable entities in the 3.x branch. Rather than using this overriding option you should create and configure you custom Geocoder Provider in the "/admin/config/system/geocoder/geocoder-provider" route.).

For the Geocoder 2.x branch/version the "Geocoder Control Specific Options" textarea input works correctly ...

hevr’s picture

ah ok, that makes a lot of sense, I just tested against 3.x and described those problems.

As an example, basically, what I'm going to do is to limit my search results to germany using at the moment the nominatim Provider:
http://nominatim.org/release-docs/latest/api/Search/#result-limitation

There is a generic geocodeQuery() method, used by the Providers:
public function geocodeQuery(GeocodeQuery $query): Collection;

GeocodeQuery accepts configs, like the one mentioned above and I would like to pass those options via query parameter because (1) I think it would be useful to dynamically configure an existing Provider instead of creating an own Provider for each config setting and (2) this way one Provider could handle multiple exposed filters or whatever you're going to use to request the API Endpoint.
It would be possible to create for example complex query interfaces that could utilize different options.

itamair’s picture

ehi @hevr ... why are you still writing about issues regarding Geocoder Providers that are part of the 3.x branch in this issue that is related to the 2.x branch?
This is creating a lot of confusion ... and not great solution.

By the way, the 3.x branch has been created (and is diverging from the 2.x) indeed to be able to handle each Geocoder Provider as a specific D8 configuration entity. So to replicate similar but different Geocoder providers for specific internal needs of the application would be perfectly fine (IMO), in the 3.x branch.
The 2.x branch is the one still using your described approach (same geocoder provider whose options might be overridden in the geocoding/reverse_geocoding methods).

But I should admit that I didn't have time ti investigate further all this.
Regarding all this it would be nice to have not only nice suggestions but also some real implementing solution and even a patch eventually, please, rigorously not introducing regression and strictly complying with Drupal8/Php/Js coding standards (https://www.drupal.org/docs/develop/standards).

Thanks!

Status: Fixed » Closed (fixed)

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

drupalina’s picture

Probably late to the party, but would it be possible to commit this to 7x-dev for those of us who are unable to move to 8x?
Many thanks in advance.