Hello. There is a map and on it geo-cardination The search string, when you enter some terrain there, it marks this place with a marker. I take the coordinates of this place, run them in alert(); - everything works, but in the console it shows an array. So, how can I get lat and lot from this array?

 function geocodeAddress(geocoder, resultsMap) { var address = document.getElementById('address').value; geocoder.geocode({'address': address}, function(results, status) { if (status === google.maps.GeocoderStatus.OK) { resultsMap.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: resultsMap, position: results[0].geometry.location }); //Тут показывает координыта alert(results[0].geometry.location); //А тут показывет массив console.log(results[0].geometry.location); } else { alert('Geocode was not successful for the following reason: ' + status); } }); } 

I would be grateful to everyone who helps!

    1 answer 1

    Be careful lat is a function and functions must be called.

     console.log(results[0].geometry.location.lat()); console.log(results[0].geometry.location.lng()); 
    • not so I have already tried - elik
    • I do not see what kind of array there is, try this with the results [0] .geometry.location [0] .lot - Yaroslav Zaika
    • See the answer, updated. - Yaroslav Zaika
    • Similarly, I thank Friend! I did not notice the sales that these are functions inside the array - elik