Created
April 19, 2021 15:36
-
-
Save acoyfellow/2b8561b9cc0d9d780fef935f09d40fde to your computer and use it in GitHub Desktop.
PhoneSites autocomplete example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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