Get Zipcode/Postal Code from latitude and longitude Google maps

Hello All,

Currently i got coordinate Google maps (latitude and longtitude) from API, but for this i have an issue how to get Zip Code from that position in Google maps.

112.75624888888889 Google Maps

Input :

  • Latitude : -7.322969444444444
  • Longtitude : 112.75624888888889

Output Address :
Jl. xxxxxxxxxxxxxxx, yyyyyyyyyyyy, Kec. Tenggilis Mejoyo, Kota SBY, Jawa Timur 60292

Expected Output :

For this case i can substring 5 digits string from characters so i will get ZipCode from output address.
But for the issue is the position for the Zipcode is usually on last address and before country, so i can’t substring 5 digit strings from behind.

Is any better idea to achieve this issue?


Hi [Ali Aga Mustofa,

You can use this
varString.Substring(varString.LastIndexOf(" ")+1)
where varString is a variable

You will get expected output.


1 Like

try this:

System.text.regularExpressions.Regex.match(varString, "([\d]{5})").groups(1).value


1 Like

Hi @Rounak_Kumar1,

Already try those option, it work with Zipcode in last address, but doesn’t work if any Country in last address :


Hi @jack.chan ,

Already try this with 3 different case and all of them work properly.
1. Normal Case
2. Country added in last Address
3. No ZipCode in Address

For this code, if you don’t mind, please explain to me how this code work :

System.text.regularExpressions.Regex.match(address, “([\d]{5})”).groups(1).value


1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.