I'm having trouble geocoding the Australian postcode 0821. It doesn't seem to reliably identify this postcode as being located within the Northern Territory, unlike 0820 and 0822 which work fine.
Here's an example of what I'm doing:
var gm = google.maps;
var gc = new gm.Geocoder();
var grq:google.maps.GeocoderRequest = {
address:s, region:"au"
};
var m = /[0-9]{4}/.exec(s);
if(m && m.length == 1)
grq.componentRestrictions = {
country:'au'/*, postalCode:m[1]*/
};
gc.geocode(grq,(results, status)=>{
if(status == gm.GeocoderStatus.OK) {
var latLng = results[0].geometry.location;
$.ajax({
url:`${apiUrl}near/${latLng.lat()},${latLng.lng()}`,
success: (response)=>this.parseResult(response,latLng)});
} else {
this.search.searchEnded();
console.warn("Gecode Failed",results,status);
alert('Unable to find location, try entering more specific search');
}
This example also seems to show similar problems. Instead of identifying 0821 in Australia, it shows it in Buenos Aires when searching 'Australia 0821' or '0821 Australia'. However, searching 'Australia 0822' works fine.
I've even tried using postal code restrictions, but that only made things worse.
How can I reliably geocode a postcode?