Get the Google API Key
- Login to https://console.developers.google.com
- Get the API Keys.
- Enable "Google Places API Web Service" from Google Google Map API
HTML Code
JavaScript Code
var lat var lon function initialize() { var input = document.getElementById('search'); var autocomplete = new google.maps.places.Autocomplete(input); google.maps.event.addListener(autocomplete, 'place_changed', function() { var place = autocomplete.getPlace(); lat = place.geometry.location.lat() lon = place.geometry.location.lng() }); } google.maps.event.addDomListener(window, 'load', initialize);
View Demo