Hi nauna,
Refer the below code.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&key=GoogleApiKey"></script>
<script type="text/javascript">
$(function () {
$('#btnGetPinCode').on("click", function () {
var lat = $('#txtLatitude').val();
var long = $('#txtLongitude').val();
GetPinCodeFromLatLong(lat, long);
return false;
});
});
function GetPinCodeFromLatLong(lat, lng) {
var latlng = new google.maps.LatLng(lat, lng);
var geocoder = geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': latlng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var address = results[0].formatted_address;
var pin = results[0].formatted_address.split(',')[results[0].formatted_address.split(',').length - 2].trim().split(' ')[1];
alert("Address: " + address + "\n\nPinCode: " + pin);
}
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<center>
<table>
<tr>
<td>
Latitude
</td>
<td>
<asp:TextBox ID="txtLatitude" runat="server" />
</td>
</tr>
<tr>
<td>
Longitude
</td>
<td>
<asp:TextBox ID="txtLongitude" runat="server" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnGetPinCode" Text="Get PinCode" runat="server" />
</td>
</tr>
</table>
</center>
</form>
</body>
</html>
Screenshot