Using Google Map API for getting the boundary and Coordinates for Zipcode.
While geocoding the Address for Saudi Arabia(SA) Region, when the Zipcode of Saudi Arabia(SA) is geocoded the Result of geocoder has address referring to 2517 The Hague, Netherlands
{
"results" : [
{
"address_components" : [
{
"long_name" : "2517",
"short_name" : "2517",
"types" : [ "postal_code", "postal_code_prefix" ]
},
{
"long_name" : "The Hague",
"short_name" : "The Hague",
"types" : [ "locality", "political" ]
},
{
"long_name" : "The Hague",
"short_name" : "The Hague",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "South Holland",
"short_name" : "ZH",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Netherlands",
"short_name" : "NL",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "2517 The Hague, Netherlands",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 52.0958783,
"lng" : 4.3007563
},
"southwest" : {
"lat" : 52.0773935,
"lng" : 4.2732776
}
},
"location" : {
"lat" : 52.0847639,
"lng" : 4.2801843
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 52.0958783,
"lng" : 4.3007563
},
"southwest" : {
"lat" : 52.0773935,
"lng" : 4.2732776
}
}
},
"place_id" : "ChIJI9DHzc6wxUcR1s1th0GbWgQ",
"types" : [ "postal_code", "postal_code_prefix" ]
},
{
"address_components" : [
{
"long_name" : "2517",
"short_name" : "2517",
"types" : [ "postal_code" ]
},
{
"long_name" : "Russell Vale",
"short_name" : "Russell Vale",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Wollongong City Council",
"short_name" : "Wollongong",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "New South Wales",
"short_name" : "NSW",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Australia",
"short_name" : "AU",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Russell Vale NSW 2517, Australia",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : -34.3338503,
"lng" : 150.9245951
},
"southwest" : {
"lat" : -34.3654418,
"lng" : 150.8740632
}
},
"location" : {
"lat" : -34.3454996,
"lng" : 150.9016476
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : -34.3338503,
"lng" : 150.9245951
},
"southwest" : {
"lat" : -34.3654418,
"lng" : 150.8740632
}
}
},
"place_id" : "ChIJSaEBIk8eE2sRQIa6P2t9ARw",
"postcode_localities" : [ "Russell Vale", "Woonona" ],
"types" : [ "postal_code" ]
}
],
"status" : "OK"
}
Since the results were not related to Saudi Arabia, added the country restrictions in the api. But it results has Partial Results value True, which refers the results are not accurate and it result has only the default value of Saudi Arabia location
https://maps.googleapis.com/maps/api/geocode/json?address=2517&components=country:SA
{
"results" : [
{
"address_components" : [
{
"long_name" : "Saudi Arabia",
"short_name" : "SA",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Saudi Arabia",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 32.1542839,
"lng" : 55.6666999
},
"southwest" : {
"lat" : 16.379528,
"lng" : 34.5489978
}
},
"location" : {
"lat" : 23.885942,
"lng" : 45.079162
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 32.1542839,
"lng" : 55.6666999
},
"southwest" : {
"lat" : 16.379528,
"lng" : 34.5489978
}
}
},
"partial_match" : true,
"place_id" : "ChIJQSqV5z-z5xURm7YawktQYFk",
"types" : [ "country", "political" ]
}
],
"status" : "OK"
}
But when the Address of Street/Region is added with Zipcode the geocode works https://maps.googleapis.com/maps/api/geocode/json?address=2517+Ar+Riyadh&components=country:SA
Is there is way to force Gmap api to geocode the only with zipcode for the Saudi Arabia country and result is accurate coordinates and Boundary?
It looks like the postal code coverage is not quite good for Saudi Arabia.
You can search postal codes using a component filtering, however often you get ZERO_RESULTS for missing postal codes.
For example,
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A12631%7Ccountry%3ASA
returns a postal code, but
https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A31433%7Ccountry%3ASA
returns ZERO_RESULTS.
For missing postal codes you can use the "Send Feedback" link on the bottom right corner of the maps.google.com.
https://support.google.com/maps/answer/162873
Hope it helps!