- Issue created by @jcornuz@gmail.com
- 🇨🇦Canada jcornuz@gmail.com
Thanks for your super quick feedback.
It doesn't work, I am afraid: I always end up with "None" selected - even if a province is already selected :(
- 🇨🇦Canada joseph.olstad
@jcornuz, this change is in the dev release, are you using the tagged release? or did you patch?
- 🇨🇦Canada jcornuz@gmail.com
I did patch version 1.0.8 in my previous report.
I have since uninstalled and reinstalled the git version (composer require drupal/address_suggestion:1.0.x-dev) and cleaned cache (drush cr) a few times just to make sure.
Still no dice... same problem :/
(tried an icognito browser window to make sure it wasn't a local cache issue)Everything else in the dev version works fine, by the way :)
- 🇫🇷France lazzyvn paris
could you debug modules/contrib/address_suggestion/js/address_suggestion.js
Line 20
if(ui.item.state != '') { form_wrapper.find('select.administrative-area').val(ui.item.state); } else if(ui.item.administrative_area != '') { form_wrapper.find('select.administrative-area').val(ui.item.administrative_area); }
or I think the list of selected provinces is in French but ui.item.administrative_area returns English, so it can't match the value
- 🇨🇦Canada jcornuz@gmail.com
I sprinkeld the code with console.log stuff (don't know how to do better :P )
ui.item.state is undefined and then the if code is executed (not the else if)
So I tried the following (after a bit of googleing)
if(typeof ui.item.state !== "undefined") {
form_wrapper.find('select.administrative-area').val(ui.item.state);
} else if(typeof ui.item.administrative_area !== "undefined") {
form_wrapper.find('select.administrative-area').val(ui.item.administrative_area);
}and it is now working... but I don't know if it is the right fix?!?
By the way, Google Map (the provider I use) returns QC for our province which is the correct value in the address drop down.
- 🇫🇷France lazzyvn paris
Retry with dev version i commited.
If you use google api could you check endpoint with https://maps.googleapis.com/maps/api/place/autocomplete/json I think it saves a little money if you don't fill in the endpoint then it will use it https://maps.googleapis.com/maps/api/geocode/json for api default.you can google for tarif place vs geocode. I know it must have session-token. But I dont have api key to checkit. do by yourself in address_suggestion/src/Plugin/AddressProvider/GoogleMaps.php try to get session token from first request and add to
$query += [ 'types' => 'address', 'location' => '0,0', 'radius' => 1, 'sessiontoken' => $session_token, ];
Make a patch if you can
- 🇨🇦Canada jcornuz@gmail.com
Yes the patch works. Thanks for taking the time to sort that out!
Hum, I hadn't realized that I was going to be charged by Google per API call (I thought there as a free tier and given the scope of my project, I would be within its limits).
Moved on to Photon for the time being (we will see what the client decides about it)
- Status changed to Fixed
12 months ago 11:12am 19 November 2023 Automatically closed - issue fixed for 2 weeks with no activity.