I have an input that uses basic google places api to get address however I cannot figure out how to get it to display the zip code between state and country. Im assuming i need to add something within this block but even if I remove it still works, so im unsure what too do.
for example type in 576 ballman rd and it will display this
576 Ballman Rd, Reynoldsburg, OH, USA
i would like to say this
576 Ballman Rd, Reynoldsburg, OH,43068 USA
im not sure how to add the zip code.
{
fields: ["address_components"],
types: ["address"],
}
here is the full code below
<!doctype html>
<html lang="en">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">
</script>
<script>
function initMap() {
window.alert('initMap fired');
const autocompleteInput = document.getElementById('location');
const autocomplete = new google.maps.places.Autocomplete(autocompleteInput, {
fields: ["address_components"],
types: ["address"],
});
console.log('hello');
console.log('nope');
}
</script>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>make zip code show</title>
</head>
<body>
<script>
window.onload = initMap;
</script>
<div class="mb-3">
<input type="text" class="form-control" id="location" name="address" size='50'>
<br>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&libraries=places&channel=GMPSB_addressselection_v1_cAB" async defer></script>
</body>
</html>