Hi nauna,
Use option parameter and set enableHighAccuracy to true.
The Default value is false.
enableHighAccuracy accepts a boolean value that indicates the application would like to receive the best possible results.
If true and if the device is able to provide a more accurate position, it will do so.
Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power.
HTML
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_Key"></script>
<script type="text/javascript">
function ViewAddress() {
navigator.geolocation.getCurrentPosition(
function (position) {
var LatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var geocoder = geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': LatLng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
document.getElementById('txtaddress').value = results[0].formatted_address;
}
});
}, function (error) {
alert(error.code + ": " + error.message);
}, {
enableHighAccuracy: true,
maximumAge: 10000,
timeout: 5000
});
}
</script>
<input type="text" id="txtaddress" />
<input type="button" id="btnView" value="View" onclick="ViewAddress()" />