Postcode Integration for UK


#41

@emre excuse my ignorance but is that the script then? to look up address from postcode?


#42

Don’t care it :slight_smile: I’ve created an Auto Configuration Task for that. I’ll be happy if you can test how it works and let me know your thoughts about default custom fields it creates. Please Update Tasks to fetch latest update.

PS: I create these posts (code, links, etc) to keep stuff together to use it as a reference later.


#43

I have to say that is looking awesome :smile: HOWEVER it seems to be using Town for Country as well. although saying that my address does not, it has the village as town and the town as county.
Maybe the levels are up one or one has been missed :-/
Or possibly area is referring to the postal area, eg my address the town level would be Moreton but thats also the Postcode Office area GL56
Think county is actually the ‘city/district’ level.

Couple of other minor notes but imagine they are both problems at googles end;
Have tried with half a dozen addresses from my recent ebay sales and other than one it didnt like and gave $2 $3 abnd $4 which is more likely a google issue however shows address if searched on google maps :-/
Also seems to be guessing the street but imagine that is googles end, probably where it translates the postcode to long and lat.


#44

I’ve implemented just the sample code you’ve posted. It might need improvements. If you give some examples about postcodes with issues I can check them.

Also If you can give some more details about correct versions of these post codes I can test. I really can’t validate if these place names (somewhereshire) should be town or county.


#45

Understandable :smile:
I will have a better experiment and see if I can see exactly where the issue is.


#46

:bell: Still waiting for the feedback :slight_smile:


#47

Sorry, have been flat out,
Did have a quick look and it wasn’t always duplicating the one so obviously address depended, think it was that county was actually postal sorting area.
Understand your bit familiar with UK address structure. :smile:
Ideally to understand what data your pulling from google I could do with seeing what the options are, ie all the fields available.
Is the options the ones at the bottom of that code?
Postcode
Street
Local
Town
Area


#48

We’re fetching 3 values from google maps. That source code slightly changed. The latest one in Auto Configuration. This is not a big deal.

Following the address format in the source code you’ve pasted I’ve named that 3 values in order as “Street”, “Town”, “County” by default. Auto configurator creates custom fields for these values if not already exists. Also while mapping $1 will be Post Code itself, $2 will be Street, $3 will be Town and $4 will be County.

What I’m wondering is if I’ve named them properly. These are default values so user can customize them but I want default to work fine for most people.

Edit: GL569NY postcode resolves as:

Street: Wolford Road
Town: Todenham
County: Moreton-in-Marsh

How it looks?


#49

Well seems like it does not work fine. We should break up addresses differently. The first result google actually returns for GL569NY’s lat&long is GL569NZ so it is incorrect.

@JTRTech do you have any idea how administrative_area_level_x values corresponds to real addresses in this result? http://maps.googleapis.com/maps/api/geocode/json?latlng=52.0194863,-1.6579531&sensor=false

administrative_area_level_1 = seems like Country  
administrative_area_level_2 = Gloucestershire   = ?
administrative_area_level_3 = Cotswold District = ?
administrative_area_level_4 = Todenham          = ? also appears as locality
postal_town                 = Moreton-in-Marsh  = Town ?
route                       = Wolford Road      = Street ?
postal_code                 = seems like Postal Code

#50

It can get tricky as to what level things are meant to be called as most address forms have;
Address 1
Address 2
Street
Town County
Postcode
But obviously as you write them you may not use the multiple address lines if short address, usually in town.

As far as my postcode used here;
administrative_area_level_1 = seems like Country
administrative_area_level_2 = Gloucestershire = ?
administrative_area_level_3 = Cotswold District = ?
administrative_area_level_4 = Todenham = ? also appears as locality
postal_town = Moreton-in-Marsh = Town ?
route = Wolford Road = Street ?
postal_code = seems like Postal Code

Gloucestershire should be the county.
Moreton-in-Marsh is the nearest town, Todenham is the village
Wolford Road is not in my address however I imagine this is google finding the nearest street as my address is just;
House Name,
Todenham (Village)
Moreton-in-Marsh (Town)
Gloucestershire (County)
GL569NY (Postcode)

However village is not a regular field for addresses…
Cotswold District is a council/government type catagory and would not usually be used in actual addresses.
Could do with a couple more sample postcodes to compare.

Here are a few sample addresses from some places Ive recently posted things to;


#51

OK. Thank you very much for the examples. It helped a lot. I’ve updated related configuration task.

I’ll request something. Can you please update your configuration tasks, run task again and let me know if current implementation works fine or not?

PS: This will be also a test for how configuration tasks updates lol.


#52

Task updated well :smile: and fields seem correct.
Think you need an extra field.
My postcode which to be fair has no street name but misses the village.
The village shows as admin level 4 (locality) in your post above.
To confirm what this should be called I would have to be able to compare the results with other postcodes.
You seem to have 'area defind as a return in the script but no field for it, would it be $5


#53

lol I thought I should skip that. My poor English :slight_smile:

Should we create a new custom field as village? Maybe we can use it interchangeably with street. I mean if street exists it will be street if not level 4 used.


#54

Interchangeable - FANCY :smile:
Sounds like that might work…

Would need to run through a few test queries to verify.
I think its more where Address 1 and Address 2 come in on most forms.

How can I see the list of outputs from a postcode search using the API? So I can run a few test queries…

Address 1 (House Name/Number)
Address 2 (Village/Apartment etc)
Street
Town
County
Postcode

My full address is quite long

House
xxx Yard, xxx Farm
Todenham
Moreton-in-Marsh
Gloucestershire

When ordering online I often have to squeeze bits in if they don’t offer the multiple address fields as above.
Always get here though - local postman works it out LOL


#55

I’ve updated configuration.

Should we rename street field as that field can also display village?


#56

What is the street field now then? Street or if blank Admin level 4?

Very odd, if I do the hotel in town (Moreton) at GL560AW Moreton-in-Marsh comes up as street and town…


#57

hello boss, could you please step by step guide for post code look up using google api, thanks a lot


#58

You dont need a tutorial, kendash made a configeration task for it, just run that and follow the steps…


#59

could you please share the kendash configuration task link, thanks a lot


#60

It is built in to software. Goto Main Menu->Manage->Setting->Configulation Tasks