Created
April 10, 2013 07:51
-
-
Save stefanfoulis/5352655 to your computer and use it in GitHub Desktop.
google places autocomplete widget limited to cities
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 type="text/javascript" src="http://www.google.com/jsapi"></script> | |
<script type="text/javascript"> | |
google.load("maps", "3.x", {callback: initialize, other_params:'sensor=false&libraries=places'}); | |
function initialize() { | |
var input = document.getElementById('id_location'); | |
var autocomplete = new google.maps.places.Autocomplete(input, { types: ['(cities)'], region:'EU' }); | |
google.maps.event.addListener(autocomplete, 'place_changed', function() { | |
var place = autocomplete.getPlace(); | |
if (!place.geometry) { | |
console.log('no location'); | |
return; | |
} | |
console.log(place); | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment