newism / craft3-fields

Address, telephone, email, embed and gender fields for CraftCMS 3.x
Other
54 stars 16 forks source link

Autocomplete doesn't populate all fields #46

Closed XianHain closed 7 months ago

XianHain commented 5 years ago

The Autocomplete box does not populate the name or subpremise (apt/suite/etc) values

Expected Behavior

When using autocomplete to find a location (example, "Mailchimp Atlanta United States"), the value "Mailchimp" would be populated in the company field, "675 Ponce De Leon Ave NE" would populate in the first Address field, and "Suite 5000" would populate in the second Address field.

Actual Behavior

When using autocomplete to find a location (example, "Mailchimp Atlanta United States"), the value "675 Ponce De Leon Ave NE" populates in the second Address field, and the Company field and first Address field are left empty.

Notes

As pointed out in #32, it's confusing for US users when the street address is populated on the second line. It would be nice if there was a way for the plugin to swap fields depending on the user's locality.

leevigraham commented 5 years ago

Thanks for raising the issue… Do you know when premise and subpremise were added to the response?

How would you expect these to be added to the address… maybe in Address Line 1.

I'm mapping two different datasets / formats Google Geocode to the CommerceGuys addressing model

Hows this for a plan… If there's a premise, subpremise or floor in the Google data I'll add that to Line 1 and the street number and name to Line 2… if those values don't exist I'll add the street number and name to Line 1.

leevigraham commented 5 years ago

@CRHain88 According to https://github.com/newism/craft3-fields/issues/32#issuecomment-414557769 the street address must always be before the premise, subpremise?

leevigraham commented 5 years ago

Reference: UPS Secondary Address Unit Designators: https://pe.usps.com/text/pub28/28c2_003.htm

leevigraham commented 5 years ago

Reference Australian Addressing Standards: https://auspost.com.au/content/dam/auspost_corp/media/documents/Appendix-01.pdf

leevigraham commented 5 years ago

@CRHain88 UPS provides an alternative position for Secondary Address Unit Designators

Screen Shot 2019-03-28 at 15 21 00

XianHain commented 5 years ago

@leevigraham Typical convention for US Addresses is as follows:

street_address premise subpremise locality administrative_area_level_1 postal_code country

the street address must always be before the premise, subpremise?

Whether you decide to put street_address above or below premise and subpremise is a matter of taste but very confusing without field labels. Many forms I've seen will say things like "Street Address", "Apt/Bldg/Ste".

This is only a concern in the control panel, I can handle the positioning of these elements in my templates.

Hows this for a plan… If there's a premise, subpremise or floor in the Google data I'll add that to Line 1 and the street number and name to Line 2… if those values don't exist I'll add the street number and name to Line 1.

I think it would be better to label the input fields and perhaps expose that data for the twig templates to arrange as the end-user sees fit. I would have to test for premise accross several addresses to see what Google populates it with.

adrienne commented 5 years ago

@leevigraham - this is related to my earlier issue, btw.

leevigraham commented 3 years ago

@CRHain88 revisting this backlog issue… The main challenge here is the way the google autocomplete api maps to the addressing bundle which handles all the country / state / city localisation and layout. The addressing bundle data model is different: https://github.com/commerceguys/addressing#data-model I probably need to rethink the purpose of the address field and explain it better.

leevigraham commented 3 years ago

Sprout Address Fieldtype for reference does the same thing: https://sprout.barrelstrengthdesign.com/docs/fields/address-field.html#templates