How to Integrate UK Postcode

Like this i need for Singapore

Yes just change the country in the script. Install the task and then go to Automation then Scripts and change the script for your country.

Thanks for your reply
i did that it shows area name not showing block name
( 72 Geylang bahru Singaore 330072) must show this way

this wrong

It will need to be modified for your output then.

function Read(postcode)
{
var country = ‘SG’
var urlfmt = 'https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyApNC6sXfhlNF-NPuKNZvp5-jtNGP2_myw&components=postal_code:’+postcode;
if(country != undefined)
urlfmt += ‘|country:’+country;
var content = web.Download(urlfmt);
var obj = JSON.parse(content);
var lat = obj.results[0].geometry.location.lat;
var lng = obj.results[0].geometry.location.lng;

var addrurl = ‘https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyApNC6sXfhlNF-NPuKNZvp5-jtNGP2_myw&latlng=’ + lat + ‘,’ + lng + ‘&sensor=false’
var addr = web.Download(addrurl);
var addrObject = JSON.parse(addr);

var data = GetAddressComponents(addrObject.results,postcode);
if(data == null) return postcode;

var street = ReadComponent(‘route’,data);
if(street == ‘-’)
street = ReadComponent(‘locality’,data);
if(street == ‘-’)
street = ReadComponent(‘administrative_area_level_4’,data);
var town = ReadComponent(‘postal_town’,data);
var county = ReadComponent(‘administrative_area_level_2’,data);

return postcode + ‘,’ + street + ‘,’ + town + ‘,’ + county;
}

function GetAddressComponents(results,postcode)
{
for(i=0;i < results.length;i++)
{
for(j=0; j< results[i].address_components.length;j++)
{
var component = results[i].address_components[j];
if(component.long_name.replace(’ ‘,’’) == postcode.replace(’ ‘,’’))
return results[i].address_components;
}
}
return null;
}

function ReadComponent(name,components)
{
for(i=0;i<components.length;i++)
{
var component = components[i];

  for(j=0;j<component.types.length;j++)
  {
     if(component.types[j] == name)
       return component.long_name;
  } 

}

return ‘-’;
}

Using this Postal Code : 330072 need to show ( 72 Gerlang Bahru Singapore 330072)
Using this Postal Code : 349316 need to show ( 41 Kallang Pudding Road, Singapore 349316)

A postcode surely doesn’t have only one number per postcode?
This is not how Google api works, it doesnt return a list of addresses within that postcode, it returns the street/area of the code.
In rural England here a postcode can be a whole village of several street/road names and it just returns the village name without street.
If you want a list of addresses for a postcode you will need to either use a address lookup api service or purchase an address list database.

Thanks for reply

in Singapore each block & each building have one unique postal code. only 6 digit number
6-digit postal code

========

The 6-digit postal code is made up of the sector code and the delivery point. The sector is represented by the first two numbers of the postal code. The remaining four numbers define the delivery point within the sector. e.g.

88 Geylang Bahru
Singapore 339696

33 is the sector code; 9696 is the delivery point, i.e. house or building.

For Housing and Development Board (HDB) residential blocks, the block number is included in the postal code. e.g.

Blk 252 Ang Mo Kio Ave 4
Singapore 560252

HDB residential blocks with the same number in the same postal sector are differentiated by their postal codes as follows:

Blk 110 Simei Street 1
Singapore 520110

Blk 110 Tampines Street 11
Singapore 521110

The postal codes for private residential, com

You would need to modify the script for your needs.

Also if you put the Singapore postcode into google maps, does it show the address including block? If it does then you can modify the code. If it doesn’t, google maps isn’t storing to that level then you can’t do anything about it and will need to look for an alternative solution.

Just remember even the api code is similar this is a UK postcode lookup feature so is designed to work for the UK. It can be modified I have done it before but you will need to dig deeper into the api to understand what to change.

How did you do this? I really want to copy this page and add my data in. Did you do it with a script? Can I have a copy of it?