Hi nauna,
Refer below code.
HTML
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_Key"></script>
<script type="text/javascript">
function ViewCoOrdinate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (p) {
var LatLng = new google.maps.LatLng(p.coords.latitude, p.coords.longitude);
var geocoder = geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': LatLng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
document.getElementById("txtLocation").value = results[1].formatted_address;
}
}
});
});
} else {
alert('Geo Location feature is not supported in this browser.');
}
return false;
}
</script>
<input type="text" id="txtLocation" />
<input type="button" id="btnView" value="View" onclintclick="return ViewCoOrdinate()" />