doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 8 forks source link

Allow autocompletion for both street fields #42

Closed MoritzLost closed 2 years ago

MoritzLost commented 2 years ago

As per the documentation, the address lookup and autocomplete mechanism is currently tied to the first subfield that appears in the address field.

Only the first subfield will conduct a lookup. This is usually the "Street Address", but the autocomplete mechanism will be bound to whichever subfield appears first.

The problem with that is that sometimes, the street address has to go in the second field (street2) because the first field (street1) is used for the addressee. Currently, the only way to utilize autocomplete in this case is a bit involved:

  1. Enter the street address in the first field and click on the autocomplete to fill out the address parts and coordinates.
  2. Copy the street address from the first to the second field.
  3. Enter the addressee in the first field.

It would be great if the field allowed autocomplete for both street fields, so one could enter a street address in either street1 or street2 and get autocomplete suggestions. Maybe this could even be made configurable? That is, have an option whether autocomplete triggers on the first or second street field or both. The current behaviour (autocomplete on the first field) could be a sensible default. In this case, the last option (autocomplete for both fields) is important though – for our use-case, the street address may be entered in either the first or the second field, so just switching the autocomplete to the second field wouldn't work in this case.

zizther commented 2 years ago

Something I noticed related to this is the top field is the only field where the autocomplete works on. In the case where I have the name field at the top of the field the address field the autocomplete features does not work on street1 or street2. For example in the case where an address does not include anything in the name field, entering the address into the street1 or street2 fields, the autocomplete does not show, but it does when I type in the name field.

If I remove the name field and street1 is the first field the autocomplete will work on this field only.

As @MoritzLost suggested it would be good to have autocomplete work on street1 and street2 at least. In my scenario above there is no need for the name field to have autocomplete.

MoritzLost commented 2 years ago

@zizther Good point, I totally agree! I like having the name field in principal, since some addresses need to include an addressee and right now we're sort of mis-using street1 and street2 for that purpose. But we can't use the name field if the autocompletion triggers only for the name field, since that often contains the addresse which won't yield any autocomplete results. So yeah, having the option to attach the autocompletion to either or all of those fields would be great.

MoritzLost commented 2 years ago

@lindseydiloreto This issue has been open for a while, could you just provide a rought estimate on whether you consider this an issue and if you'll consider the suggested solutions? Would be great just to get a bit of feedback – the new name field would be perfect for one of my projects, but because of this issue, I can't use it. So I'd like to know if I can count on this functionality in the medium to long term.


Just some additional context: I've properly tested the autocomplete with the new name property now, it's great that the autocomplete supports both street addresses and the places API! Still, not every address we need to enter is going to have an entry in the places API, so for those, the street1 field would need to trigger the autocompletion or require manual workarounds.

lindseydiloreto commented 2 years ago

@MoritzLost This is actually pretty high on my radar. I recently chatted with @zizther about this exact issue.

I plan to add a series of checkboxes, so you can select which subfield(s) should perform the autocomplete lookup.

I'm not sure my exact timeline, but with any luck it will be out within the next 2-4 weeks.

MoritzLost commented 2 years ago

@lindseydiloreto Awesome, that would be really great! Thanks for the reply! 🚀

lindseydiloreto commented 2 years ago

This is done, and released with v4.1.3. 👍

You can manually select which subfields you want to use Autocomplete. Multiple subfields can safely use Autocomplete at the same time.

Auto
MoritzLost commented 2 years ago

@lindseydiloreto Awesome, thanks! I'll give this a try soon :)