Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PhoneSites autocomplete example
<script async
src="https://maps.googleapis.com/maps/api/js?key=***YOURAPIKEY***&libraries=places&callback=initMap">
</script>
<script>
window.initMap= function(){
const input = document.querySelector('input[name="address"]');
const options = {
componentRestrictions: { country: "us" },
fields: ["address_components", "geometry", "icon", "name"],
types: ["establishment"],
};
const autocomplete = new google.maps.places.Autocomplete(input, options);
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment