Reverse Gecoding to return full formatted address [duplicate]

I'm using reverse geococoding to read coordinates and convert them to a street address. The code i have works but my problem is that it only returns the suburb and town is it possible to format it in a way that it returns full address number - street - suburb - town - country.

 // Read coordinates and convert to Readible Address
function codeLatLng() {
geocoder = new google.maps.Geocoder();
//var input = document.getElementById('latlng').value;
//var latlngStr = input.split(',', 2);
var lat = parseFloat(latitude);
var lng = parseFloat(longitude);
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({ 'latLng': latlng }, function (results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        if (results[1]) {

            //, marker);
        } else {
            alert('No results found');
    } else {
        alert('Geocoder failed due to: ' + status);



Have you tried to change results[1] for results[0]? From Google Geocode Docs docs:

results[0].formatted_address: "275-291 Bedford Ave, Brooklyn, NY 11211, USA",
results[1].formatted_address: "Williamsburg, NY, USA",
results[2].formatted_address: "New York 11211, USA",
results[3].formatted_address: "Kings, New York, USA",
results[4].formatted_address: "Brooklyn, New York, USA",
results[5].formatted_address: "New York, New York, USA",
results[6].formatted_address: "New York, USA",
results[7].formatted_address: "United States"


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.