Google Maps Autocomplete: how to get lat/lng?

The other answers are missing a critical component. You need to include 'geometry' when you call setFields. Be aware that more fields may cost more.

Ex:

// Avoid paying for data that you don't need by restricting the set of
// place fields that are returned to just the address components.
autocomplete.setFields(['address_component', 'geometry']);

See docs


OK, I'm not familiar with Places or Autocomplete. But it looks like what you are looking for is

autocomplete.getPlace().geometry.location

To demonstrate I took this example and added the line above to create this JSFiddle where you can enter the place name and when it's selected, an infowindow with the LatLng is created.

In particular it listens to the user's selection, then refreshes the infowindow.

google.maps.event.addListener(autocomplete, 'place_changed', function() {
      infowindow.close();
      var place = autocomplete.getPlace();
       ...
      infowindow.setContent('<div><strong>' + place.name + 
        '</strong><br>' + address + "<br>" + place.geometry.location);

There are methods called lat() and lng() that exist on the geometry object's prototype. So to get the values, just use the following:

var place = autocomplete.getPlace();

var lat = place.geometry.location.lat(),
    lng = place.geometry.location.lng();

// Then do whatever you want with them

console.log(lat);
console.log(lng);

console.warn('Warning: I didn\'t test this code!');