Skip to content

Instantly share code, notes, and snippets.

@anhnt
Last active August 29, 2015 14:04
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 anhnt/c0e6625fb153cbb62793 to your computer and use it in GitHub Desktop.
Save anhnt/c0e6625fb153cbb62793 to your computer and use it in GitHub Desktop.
google place autocomplete
<!DOCTYPE html>
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
<script>
window.onload = function(){
var locationField = document.getElementById('locationField');
var input = document.createElement('input');
input.setAttribute('id','autocomplete');
input.setAttribute('type','text');
locationField.appendChild(input);
var autocomplete = new google.maps.places.Autocomplete(
/** @type {HTMLInputElement} */(document.getElementById('autocomplete')),
{ types: ['geocode'] });
google.maps.event.addListener(autocomplete, 'place_changed', function() {
});
}
</script>
</head>
<body>
<div id="locationField">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment