Google Address Validation API with Xojo?

Hello all;

I have been using Melissa Data for address validatons. It works well, except for one thing: it does not return localized address formats. In all fairness, Melissa Data has another API than I am using that probably would, but it would also cost quite a bit more to use. So, fast forward to today. I am starting to look at Google’s Address Validation API.

Has anyone succeeded to use it, and would you have recommendations implementing it in a web app? I am not looking to show the address on a map, just to send a user-entered address and to retrieve a properly formatted address.

Thanks.

LD

I am using Google Places API.
Fairly easy to use once you understand how to parse JSON.

Make sure to wrap the parsing in a Try… Catch, you might be surprised by the variety of returned data.
Log all exceptions with input and output, that will help you improve the parsing.

Make sure to save the placeId somewhere, it can be useful in the future if you need to interact with another API in the Google Maps API set.

And depending on the volume of requests, you might want to cache the output, especially if you are going to Auto-complete as the user types.
My API monthly fees would be 4-5x higher if I didn’t use caching.

1 Like

Thank you Jérémie;

It is good to know that it can be done in pure Xojo. I don’t interact with the Places API directly, but through a map viewer. I have been using Graffiti Web and enjoying Anthony’s great support. Here, I was thinking that I should interact directly, as I do with Melissa Data.

I don’t plan to offer the user any interactive autocompletion, only an address verification once it is entered, whole or partial.

Thank you again.

LD

1 Like

@Jeremie_L I’m starting a Web project that hopes to use the Google Autocomplete API. I did some tinkering and can see how the POST and RESPONSE data works, but was curious how you handle displaying the results in the UI where the user is typing. Are you using a WebTextField as the field for the user, or a different control? And when you receive the ‘suggestion’ data in the response, are you simply overriding the .Text value of the control? Just looking for tips on best way to implement this feature. Thanks!

Well, I am not @Jeremie_L , but I will offer an answer.

I parse Google’s response into properties of an address validation class. Once the parsing is complete, I update specific fields, all webtextfields, with required information, including one where the formatted address is shown (only for the benefit of the human reading the screen). If saving the address is required, the address validation class “save” method is called and the relevant data is pushed as a new address or an updated address in the database.

Thanks Louis - I appreciate your answer (and it’s OK that you are not Jeremie :wink:)

Because of the lag between the user keying in data, the ‘TextChanged’ event firing, the round-trip to server and back to browser, I was curious how to deliver the best experience. I’ve created custom WebTextFields that only submit changes when a certain amount of millisecs have transpired, to that helps, but I’m still curious about emulating the same “auto-complete” experience as you see in other applications, where a list of ‘possible’ items drops down, and the user selects the row they’d like from the options.

I am not trying to emulate the autocomplete behavior. I have a “validate” button that the user presses. Call me lazy. :wink:

If you want smooth autocomplete you should do it in javascript in the user’s browser, not in your xojo code.

1 Like

Hey there,
I am not using Google places API in a web project.
In my mobile project, I display a MobileTable below the textfield so the user can tap on the appropriate address.

And I cache all requests and results to make sure the results appear instantly if the user types the same thing twice.

I appreciate the pro-tip! Especially since Google will charge you each time you query them :slight_smile: Thanks for all the feedback!

1 Like