Skip to content

Instantly share code, notes, and snippets.

@acoyfellow
Created April 19, 2021 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acoyfellow/2b8561b9cc0d9d780fef935f09d40fde to your computer and use it in GitHub Desktop.
Save acoyfellow/2b8561b9cc0d9d780fef935f09d40fde to your computer and use it in GitHub Desktop.
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