Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to verify if the input matches the selected address? #220

Open
WillSmithTE opened this issue Aug 2, 2023 · 3 comments
Open

How to verify if the input matches the selected address? #220

WillSmithTE opened this issue Aug 2, 2023 · 3 comments

Comments

@WillSmithTE
Copy link

How do I get the actual text that was suggested to the user? The text that becomes the input's value on select?

E.g. search for 50 Abbotts Road, Dandenong South VIC, Australia

That comes up as a suggestion.

The user selects it, but then changes Abbotts to Abbots.

I thought the formatted_address would be 50 Abbotts Road, Dandenong South VIC, Australia, and I could compare this to the input value to check if they changed it. But it's not. The formatted_address is 50 Abbotts Rd, Dandenong South VIC 3175, Australia.

How do I validate this? How do I get the 50 Abbotts Road, Dandenong South VIC, Australia?

This seems to be a similar issue, but doesn't have an answer I could use with this library.
https://stackoverflow.com/questions/18454677/google-maps-api-how-do-you-ensure-that-the-google-maps-autocomplete-text-is-an

@insaurabh
Copy link

How do I get the actual text that was suggested to the user? The text that becomes the input's value on select?

E.g. search for 50 Abbotts Road, Dandenong South VIC, Australia

That comes up as a suggestion.

The user selects it, but then changes Abbotts to Abbots.

I thought the formatted_address would be 50 Abbotts Road, Dandenong South VIC, Australia, and I could compare this to the input value to check if they changed it. But it's not. The formatted_address is 50 Abbotts Rd, Dandenong South VIC 3175, Australia.

How do I validate this? How do I get the 50 Abbotts Road, Dandenong South VIC, Australia?

This seems to be a similar issue, but doesn't have an answer I could use with this library. https://stackoverflow.com/questions/18454677/google-maps-api-how-do-you-ensure-that-the-google-maps-autocomplete-text-is-an

You can use ref to get the value from INPUT field, then compare that data with formatted_address.

@WillSmithTE
Copy link
Author

@insaurabh thanks, but that's the issue. The formatted address is different to the input field's value.

e.g.

inputValue: '37 Bessemer Street, Kings Park NSW, Australia'
formattted: '37 Bessemer St, Kings Park NSW 2148, Australia'

They are slightly different.

@insaurabh
Copy link

@WillSmithTE

You can update the

options: {
types: ["(regions)"], <--- to address or some valid type, check google doc.
},

and then on selection of address, create your own dropdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants