Пожалуйста, попробуйте следующий код, добавив свой ключ API, он отлично работает для меня
$(document).on('click', "#autocomplete", function () {
var currentInp = $(this).attr("id");
var $tabletextbox = $(this);
var autocomplete = new google.maps.places.Autocomplete(document.getElementById(currentInp));
autocomplete.addListener('place_changed', function () {
var place = autocomplete.getPlace();
if (!place.geometry) {
// User entered the name of a Place that was not suggested and
// pressed the Enter key, or the Place Details request failed.
window.alert("No details available for input: '" + place.name + "'");
return;
}
for (var i = 0; i < place.address_components.length; i++) {
if(place.address_components[i].types[0] == 'postal_code'){
alert(place.address_components[i].long_name);
}
}
$('#lat').val(place.geometry.location.lat().toFixed(8));
$('#lng').val(place.geometry.location.lng().toFixed(8));
});
});
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=Your API Key&libraries=places"></script>